开发者

How to auto link classes when compiling c++ in eclipse?

I am writing software in eclipse and i am using libcurl. In order for me to compile it, i have to go to the terminal(ubuntu) and after cd-ing to the directory wiht the .cpp file, i have to run this:

g++ -g -Wall -o myapp myapp.cpp -L/usr/local/lib -lcurl

How do I configure the eclipse compiler to ru开发者_如何学Gon this when comiling for me, instead of me having to run the terminal everytime.

Any help? Thanks.


project -> properties -> c/c++ build -> settings -> gcc c++ linker -> libraries

click on green + icon add your library name (without -l)


You have to choose a tool chain and and add a make file target. You can try to create a new Hello World project (file--> New --> C++ project --> Hello World C++-Project ) and add after that adapt to your needs (do renaming, add your classes)... After creating the project it should be visible in the Project explorer. Open the Makefile and set

  • CXXFLAGS = -g -Wall -L/usr/local/lib
  • LIBS = -lcurl
  • TARGET = myapp
  • OBJS = myapp.o

Open the Make Target View (Window-->Show View --> Make Target) and add a target to build your all target of the Makefile. You may do this by:

  1. In the Make Target View open the context menu by clicking right on your created/listed project.
  2. Choose New...
  3. Enter all as target name
  4. Click (double click) on all to start the build process
  5. Check the console output

Hope this may help

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜