|
Re: Source codes that compile with command line but not in eclipse [message #1775763 is a reply to message #1775760] |
Mon, 06 November 2017 06:07 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
The way 'make' works from the command line (without any options) is to
1) find the proper make file (there is a standard order of names to choose)
2) build the first target in that file.
In your case, the first target is "default"
The bult-in target Eclipse uses is "all" so it calls make with
cd <build configuration directory>
make all
This enters the configuration directory (the current configuration name often Debug or Release)
Then tells make to build target "all".
Either change the first target name from "default" to "all" or
Add a target "all" or
Add "default" as a target using the "Target View"
which you can add with Window --> Show View --> Build Targets
You will need to select and build this target every time.
Your makefile was not generated by Eclipse.
To see how Eclipse builds one, add the "Hello World" project and build it.
Then note the directory structure.
You don't have to use this structure (I don't for Makefile Projects) but
you still need to ensure Eclipse will try to set the directory containing the Makefile as the working directory during the build.
Project --> Properties --> C/C++ Build --> Builder Settings tab --> Build Directory
For you: ${workspace_loc:/test_code_makefile}
[Updated on: Mon, 06 November 2017 08:29] Report message to a moderator
|
|
|
Re: Source codes that compile with command line but not in eclipse [message #1775775 is a reply to message #1775763] |
Mon, 06 November 2017 08:50 |
J M Messages: 7 Registered: November 2017 |
Junior Member |
|
|
Hi David,
Thank you for your answer.
Well I'm not sure I understand fully what you said but I added and built the "Hello World" project and I noticed that it had the same directory structure as my project.
I changed the makefile and I added the "all" and after compilation, I had linking problem errors with libraries that say : "undefined reference towards the library ...." (you'll find attached an image with errors). I don't have these errors when I compile by command line. Here's my new makefile :
all: libImageFormats libBasic libImageFormatPM libImage libHyperspectral
OBJC = libImageFormats.o
OBJ = libBasic.o libImageFormatPM.o libImage.o libHyperspectral.o
CXX=g++
C=gcc
hdrdir= -I/usr/local/include/ #-I/usr/local/opt/libpng/include
libdir= -L/usr/local/lib/ #-L/usr/local/opt/libpng/lib
COPT = -lm -O3 -funroll-loops -fomit-frame-pointer -ffast-math -ftree-vectorize
CXXFLAGS += -g $(COPT) -pedantic -Wall -Wextra -Wno-write-strings -Wno-deprecated $(hdrdir) -fopenmp
LDFLAGS += -g $(CXXFLAGS) $(libdir) -lpng -ltiff -ljpeg -lfftw3 -lfftw3f -fopenmp
CFLAGS = -O3 -std=c99 -I/usr/local/include/ -L/usr/local/lib/
default: $(OBJC) $(OBJ) $(BIN)
$(OBJC) : %.o : %.c
$(C) -c $(CFLAGS) $< -o $@
$(OBJ) : %.o : %.cpp
$(CXX) -c $(CXXFLAGS) $< -o $@
$(BIN) : % : %.o
$(CXX) $(LDFLAGS) -o $(LIBBIN)/$@ $^
.PHONY : clean
clean:
$(RM) $(OBJ) $(OBJC) ;
Thank you in advance for you help.
Sincerely,
-J
[Updated on: Mon, 06 November 2017 09:13] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03561 seconds