Use shared library linked with a makefile - c++

I am trying to compile my program with the following make file. I found a template on the internet and I am trying to use it. I only modified things before # Main entry point
The make file
# Define executable name
BIN = CLI_DeskManager
# Define source files
SRCS = main.cpp shell.cpp
# Define header file paths
INCPATH = -I./ -I/usr/include/X11/exensions -I/usr/include/X11 -I/home/julien/Documents/DeskManagerDll
# Define the -L library path(s)
LDFLAGS = -L/usr/X11R6/lib -L/home/julien/Documents/DeskManagerDll
# Define the -l library name(s)
LIBS = -lX11 -lXext -Wl,--no-as-needed -lDeskManager -lpthread
# Only in special cases should anything be edited below this line
OBJS = $(CPP_SRCS:.cpp=.o)
CXXFLAGS = -Wall -ansi -pedantic -std=c++11 -pthread
DEP_FILE = .depend
# Main entry point
#
all: depend $(BIN)
# For linking object file(s) to produce the executable
#
$(BIN): $(OBJS)
#echo Linking $#
#$(CXX) $^ $(LDFLAGS) $(LIBS) -o $#
# For compiling source file(s)
#
.cpp.o:
#echo Compiling $<
#$(CXX) -c $(CXXFLAGS) $(INCPATH) $<
# For cleaning up the project
#
clean:
$(RM) $(OBJS)
distclean: clean
$(RM) $(BIN)
$(RM) $(DEP_FILE)
# For determining source file dependencies
#
depend: $(DEP_FILE)
#touch $(DEP_FILE)
$(DEP_FILE):
#echo Generating dependencies in $#
#-$(CXX) -E -MM $(CXXFLAGS) $(INCPATH) $(SRCS) >> $(DEP_FILE)
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
ifeq (,$(findstring distclean,$(MAKECMDGOALS)))
-include $(DEP_FILE)
endif
endif
The errors
But I have a lot of errors like the following one
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
But on this thread soru says that the important one is :
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [CLI_DeskManager] Error 1
Additional informations
I already successfully compiled it with Code::blocks, this is the build log.
g++ -Wall -fexceptions -std=c++11 -g -pthread -I/usr/include/X11/extensions -I/usr/include/X11 -I../DeskManagerDll -c /home/julien/Documents/CommandLineInterface_DeskManager/main.cpp -o obj/Debug/main.o
g++ -Wall -fexceptions -std=c++11 -g -pthread -I/usr/include/X11/extensions -I/usr/include/X11 -I../DeskManagerDll -c /home/julien/Documents/CommandLineInterface_DeskManager/shell.cpp -o obj/Debug/shell.o
g++ -L-L/usr/lib/i386-linux-gnu -o bin/Debug/CommandLineInterface_DeskManager obj/Debug/main.o obj/Debug/shell.o -L/usr/X11R6/lib -lX11 -lXext -Wl,--no-as-needed -lpthread /home/julien/Documents/DeskManagerDll/bin/Debug/libDeskManagerDll.so
I found answers on StackOverflow but I don't understand them.
Link, link, link, link.
What am I doing wrong ?
Thank you.
Update after Lijat answer
Makefile after the recommended modification
# Define executable name
BIN = CLI_DeskManager
# Define source files
SRCS = main.cpp shell.cpp
# Define header file paths
INCPATH = -I./ -I/usr/include/X11/exensions -I/usr/include/X11 -I/home/julien/Documents/DeskManagerDll
# Define the -L library path(s)
LDFLAGS = -L/usr/X11R6/lib -L/home/julien/Documents/DeskManagerDll/bin/Debug
# Define the -l library name(s)
LIBS = -lX11 -lXext -Wl,--no-as-needed -lDeskManagerDll -lpthread
# Only in special cases should anything be edited below this line
OBJS = $(CPP_SRCS:.cpp=.o)
CXXFLAGS = -Wall -ansi -pedantic -std=c++11 -pthread
DEP_FILE = .depend
# Main entry point
#
all: depend $(BIN)
# For linking object file(s) to produce the executable
#
$(BIN): $(OBJS)
echo Linking $#
$(CXX) $^ $(LDFLAGS) $(LIBS) -o $#
# For compiling source file(s)
#
.cpp.o:
echo Compiling $<
$(CXX) -c $(CXXFLAGS) $(INCPATH) $< -o $#
# For cleaning up the project
#
clean:
$(RM) $(OBJS)
distclean: clean
$(RM) $(BIN)
$(RM) $(DEP_FILE)
# For determining source file dependencies
#
depend: $(DEP_FILE)
touch $(DEP_FILE)
$(DEP_FILE):
echo Generating dependencies in $#
-$(CXX) -E -MM $(CXXFLAGS) $(INCPATH) $(SRCS) >> $(DEP_FILE)
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
ifeq (,$(findstring distclean,$(MAKECMDGOALS)))
-include $(DEP_FILE)
endif
endif
Full make output. I am sorry for the fact that it is in french. There are only two different sentences that are translated in the first part of my question.
julien#julien-VirtualBox:~/Documents/CommandLineInterface_DeskManager$ make
touch .depend
echo Linking CLI_DeskManager
Linking CLI_DeskManager
g++ -L/usr/X11R6/lib -L/home/julien/Documents/DeskManagerDll/bin/Debug -lX11 -lXext -Wl,--no-as-needed -lDeskManagerDll -lpthread -o CLI_DeskManager
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 0 a un index de symbole 11 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 1 a un index de symbole 12 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 2 a un index de symbole 2 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 3 a un index de symbole 2 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 4 a un index de symbole 11 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 5 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 6 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 7 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 8 a un index de symbole 12 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 9 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 10 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 11 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 12 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 13 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 14 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 15 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 16 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 17 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 18 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 19 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 20 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 21 a un index de symbole 22 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_line): réadressage 0 a un index de symbole 2 invalide
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o: dans la fonction « _start »:
(.text+0x18): référence indéfinie vers « main »
collect2: error: ld returned 1 exit status
make: *** [CLI_DeskManager] Erreur 1

It is slightly unclear what you are trying to achieve, are you trying to create a shared library or are you simply trying to use one?
The Code::blocks log hints at the second option, if that is the case I notice that you have libDeskManagerDll.so in the Code::blocks log and -lDeskManager in the makefile, for them to be the same I would have expected that to be -lDeskManagerDll
also this line seems odd to me
#$(CXX) -c $(CXXFLAGS) $(INCPATH) $<
I would have expected it to look like
#$(CXX) -c $(CXXFLAGS) $(INCPATH) $< -o $#
If this does not resolve the problem could you remove the # signs at the beginning of lines in the makefile and post the full output of make?
UPDATE
From your update it is clear that the make does not include the object files in the linking command. On closer inspection the line
SRCS = main.cpp shell.cpp
defines the source files which you then are trying to use with
OBJS = $(CPP_SRCS:.cpp=.o)
changing that line to
OBJS = $(SRCS:.cpp=.o)
should bring you closer to what you want

Related

Makefile:4: *** missing seperator. Stop [duplicate]

This question already has answers here:
Make error: missing separator
(14 answers)
Closed 12 months ago.
This is my Makefile:
EXEC_NAME = bin/exemple bin/test
OBJ_FILES = bin/main.o bin/Image.o bin/Pixel.o
CC * g++
CFLAGS * -wall -ggdb
INCLUDES *
LIBS *
all: $(EXEC_NAME)
exemple: mainExemple.o Image.o Pixel.o*
test: mainTest.o Image.o Pixel.o
$(CC) bin/main.o bin/Image.o bin/Pixel.o -o bin/test $(LIBS)
mainExemple.o: src/mainTest.cpp src/Image.cpp src/Pixel.cpp
$(CC) $(CFLAGS) $(INCLUDES) -o bin/mainExemple.o src/mainExemple
mainTest.o: src/mainTest.cpp src/Image/h src/Pixel.h
$(CC) $(CFLAGS) $(INCLUDES) -o bin/mainTest.o -c src/mainTest.cpp
Image.o: src/Image.cpp src/Image.h src/Pixel.h
$(CC) $(CFLAGS) $(INCLUDES) -o bin/Image.o -c src/Image.cpp
Pixel.o: src/Pixel.cpp src/Pixel.h
$(CC) $(CFLAGS) $(INCLUDES) -o bin/Pixel.o -c src/Pixel.cpp
main.o: $(SRC)main.cpp $(SRC)Image.h $(SRC)Pixel.h
g++ $(FLAGS) -c $(SRC)main.cpp -o $(OBJ)main.o
clear:rm $(OBJ)*.o
and i get : Makefile:4: *** missing seperator. Stop.
Where is my mistake?
Use tabs not spaces
Line 4 to 8 - you can't just have frefloating commands like bash. You need them to be part of something.

Makefile: (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status

I have a problem with a Makefile. Maybe the problem is the linker, but I can't
find the error. At some point (CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o #
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Makefile:65: recipe for target 'doMyAnalysisHeavyIon' failed
make: *** [doMyAnalysisHeavyIon] Error 1
Makefile:
1 all: libs programs
2
3 libs: HxSimParticle_cxx.so HxSimEvent_cxx.so
4
5 programs = doMyAnalysisHeavyIon
6
7 #LHAPDF = LHAPDF-6.1.6
8 PYTHIA8 = /home/andre/pythia8235
9 HXPATH = /home/andre/pythia8235/examples/Analysis
10
11 # define compiler/linker flags
12 CXX = g++
13
14 CXXFLAGS = -O3 -Wall -fPIC
15 CXXFLAGS += $(shell root-config --cflags)
16 CXXFLAGS += $(shell fastjet-config --cxxflags)
17 CXXFLAGS += -I$(HXPATH)
18
19 #LDFLAGS = -O3
20 LDFLAGS = -O3 -Wl,-rpath,'$(HXPATH)'
21 LDFLAGS += $(shell root-config --ldflags)
22 #LDFLAGS += -Wl,-rpath,$(PYTHIA8)/lib/
23 #LDFLAGS += -Wl,-rpath,$(HXPATH)/
24
25 SOFLAGS = -shared
26
27 ROOTLIBS = $(shell root-config --libs --glibs --evelibs)
28 #ROOTLIBS += -lEG -lGui -lASImage -lASImageGui
29
30 #PDFLIBS = $(shell ${LHAPDF}/install/bin/lhapdf-config --libs)
31 #P8LIBS = $(shell $(PYTHIA8)/bin/pythia8-config --libs)
32
33 #HXLIBS = $(HXPATH)/HxSimParticle_cxx.so $(HXPATH)/HxSimEvent_cxx.so
34
35 PROGRAMS = doMyAnalysisHeavyIon
36
37 # compile/link HxSimEvent
38 HxSimEvent_cxx.so: HxSimEventDict.o HxSimEvent.o HxSimParticleDict.o HxSimParticle.o
39 $(CXX) $(SOFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o $#
40
41 HxSimEvent.o: HxSimEvent.cxx
42 $(CXX) $(CXXFLAGS) -c $^ -o $#
43
44 HxSimEventDict.o: HxSimEventDict.cxx
45 $(CXX) $(CXXFLAGS) -c $^ -o $#
46
47 HxSimEventDict.cxx: HxSimEvent.h HxSimEventLinkDef.h
48 rootcint -f $# -c $(CXXFLAGS) -p $^
49
50 # compile/link HxSimParticle
51 HxSimParticle_cxx.so: HxSimParticleDict.o HxSimParticle.o
52 $(CXX) $(SOFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o $#
53
54 HxSimParticle.o: HxSimParticle.cxx
55 $(CXX) $(CXXFLAGS) -c $^ -o $#
56
57 HxSimParticleDict.o: HxSimParticleDict.cxx
58 $(CXX) $(CXXFLAGS) -c $^ -o $#
59
60 HxSimParticleDict.cxx: HxSimParticle.h HxSimParticleLinkDef.h
61 rootcint -f $# -c $(CXXFLAGS) -p $^
62
63 # compile/link doMyAnalysisHeavyIon
64 doMyAnalysisHeavyIon: doMyAnalysisHeavyIon.o HxSimEvent_cxx.so HxSimParticle_cxx.so
65 $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o #
66
67 doMyAnalysisHeavyIon.o: doMyAnalysisHeavyIon.C
68 $(CXX) $(CXXFLAGS) -c $^ -o $#
69
70 .PHONY: clean distclean
71
72 # remove object files
73 clean:
74 #rm -f *.o
75
76 # remove objects, libraries and dicts
77 distclean: clean
78 #rm -f *.so *Dict.* $(PROGRAMS)
When building an executable linker (ld) is looking for main() to use it as a function to call / start your program with. Most likely causes would be:
You've forgotten to compile the source / link in the object where main is defined. Normally I would expect you to have it in doMyAnalysisHeavyIon.C with your Makefile content. It is however listed as prerequisite to be compiled and linked into doMyAnalysisHeavyIon.
Or there is a typo (perhaps capitalization?) causing main to not be found there? (Assuming it really isn't missing altogether? Should the result be an executable or perhaps a library?)
Line 65 is missing a dollar sign:
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o $#
I'm not sure if that is your problem. Please show the contents of doMyAnalysisHeavyIon.C, especially whether or not it contains main and if main is the correct namespace. It must be at the top level of the namespace, and defined as int main(int argc, char* argv[]) {

Makefile with -std=c++11

I am writing a makefile for my program (that is tested and works) The problem I can tell is that some how my '-std=c++11' is not running in the function. The code pops out a unrecognized error that I dont get when I simply run 'g++ -o exe -std=c++11 *.cpp'. Here is my make file.
HEADERS = card.h sortedLinkedList.h deck.h
OBJECTS = card.o sortedLinkedList.o deck.o main.o
exe: $(OBJECTS)
g++ -std=c++11 $^ -o $#
%.o: %.cpp $(HEADERS)
g++ -c -std=c++11 $< -o $#
clean:
rm -i *.o exe
The output of my makefile is
me#root:~/Documents/CS216/Lab8$ make
g++ -c -o card.o card.cpp
card.cpp: In member function ‘void Card::print()’:
card.cpp:55:28: error: ‘to_string’ was not declared in this scope
cardN=to_string(point);
^
<builtin>: recipe for target 'card.o' failed
make: *** [card.o] Error 1
note: to_string() is not defined until c++11
daniel#Reimann:~/Documents/CS216/Lab8$ ls
card.cpp deck.cpp Lab8 lab8source.zip SortedLinkedList.h
card.h deck.h lab8.cpp makefile SortedLinkedList.o
card.o deck.o lab8.o SortedLinkedList.cpp
Output of xxd makefile
00000000: 4845 4144 4552 5320 3d20 6361 7264 2e68 HEADERS = card.h
00000010: 2073 6f72 7465 644c 696e 6b65 644c 6973 sortedLinkedLis
00000020: 742e 6820 6465 636b 2e68 0a4f 424a 4543 t.h deck.h.OBJEC
00000030: 5453 203d 2063 6172 642e 6f20 536f 7274 TS = card.o Sort
00000040: 6564 4c69 6e6b 6564 4c69 7374 2e6f 2064 edLinkedList.o d
00000050: 6563 6b2e 6f20 6c61 6238 2e6f 0a4c 6162 eck.o lab8.o.Lab
00000060: 383a 2024 284f 424a 4543 5453 290a 0967 8: $(OBJECTS)..g
00000070: 2b2b 202d 7374 643d 632b 2b31 3120 245e ++ -std=c++11 $^
00000080: 202d 6f20 2440 0a25 2e6f 3a20 252e 6370 -o $#.%.o: %.cp
00000090: 7020 2428 4845 4144 4552 5329 200a 0967 p $(HEADERS) ..g
000000a0: 2b2b 202d 6320 2d73 7464 3d63 2b2b 3131 ++ -c -std=c++11
000000b0: 2024 3c20 2d6f 2024 400a 636c 6561 6e3a $< -o $#.clean:
000000c0: 0a09 726d 202d 6920 2a2e 6f20 4c61 6238 ..rm -i *.o Lab8
000000d0: 0a
I believe the problem is in this line:
HEADERS = card.h sortedLinkedList.h deck.h
#----------------^
You have specified a dependency on sortedLinkedList.h, but that file doesn't exist. You only have SortedLinkedList.h with a capital S.
The rule
%.o: %.cpp $(HEADERS)
g++ -c -std=c++11 $< -o $#
is considered for making card.o but rejected because one of the prerequisites (namely sortedLinkedList.h) doesn't exist.
So make falls back to its built-in rule for making .o files from .cpp files, which is $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c.
CXX is set to g++ by default, but CPPFLAGS and CXXFLAGS are empty. This explains the extra spaces between g++ and -c in the output:
g++ -c -o card.o card.cpp
You can confirm this by running make -r, which disables all built-in rules. It should now fail to find a rule for making card.o.
To solve this, you should fix the capitalization of SortedLinkedList.h. You should also consider using the built-in rules and just set CXXFLAGS = -std=c++11.
Generally you want to use the CXXFLAGS implicit variable to specify this switch. I am not sure why the current pattern rule is failing, but using CXXFLAGS will allow getting rid of it entirely

undefined reference to GLib

I know, that there were many questions similar to mine, but their answers didn't solve my problem.
I am trying to build the CHamsa project:
https://github.com/maxsnew/CHamsa/
Got sary, patched it, built, installed. Built the TokenEXAPI. All was great.
When finally made the CHamsa with a makefile, it gave me errors:
Makefile after typing 'make'
g++ -o siggen tracesary.o utils.o tokenExtract.o conjpattern.o sig_gen.o siggen_main.o
-lm -pthread -L/usr/local/lib -lsary -lgthread-2.0 -lglib-2.0 -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp
errors
/usr/local/lib/libsary.so: undefined reference to `g_free'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_destroy'
/usr/local/lib/libsary.so: undefined reference to `g_strdup'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_insert'
/usr/local/lib/libsary.so: undefined reference to `g_strconcat'
/usr/local/lib/libsary.so: undefined reference to `g_array_new'
/usr/local/lib/libsary.so: undefined reference to `g_array_free'
/usr/local/lib/libsary.so: undefined reference to `g_malloc'
/usr/local/lib/libsary.so: undefined reference to `g_assertion_message_expr'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_new'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_foreach'
/usr/local/lib/libsary.so: undefined reference to `g_hash_table_lookup'
/usr/local/lib/libsary.so: undefined reference to `g_strerror'
/usr/local/lib/libsary.so: undefined reference to `g_malloc_n'
/usr/local/lib/libsary.so: undefined reference to `g_array_append_vals'
/usr/local/lib/libsary.so: undefined reference to `g_log'
it looks like badly linked, because the file, which is using the glib has got:
#include <glib.h>
any ideas how can I solve this one? I am sitting here whole day googling for answers...
this one was bad:
g++ -o siggen tracesary.o utils.o tokenExtract.o conjpattern.o sig_gen.o siggen_main.o
-lm -pthread -lgthread-2.0 -lglib-2.0 -L/usr/local/lib -lsary -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp
that one too:
g++ -o siggen tracesary.o utils.o tokenExtract.o conjpattern.o sig_gen.o siggen_main.o
-lm -pthread -lgthread-2.0 -lglib-2.0 -L/usr/local/lib -lsary -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp
even that one:
g++ -o siggen tracesary.o utils.o tokenExtract.o conjpattern.o sig_gen.o siggen_main.o
-lm -pthread -L/usr/local/lib -lsary -L/usr/lib -lgthread-2.0 -lglib-2.0 -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp
EDIT
Makefile looks like that:
###############################################################################
#
# File: Makefile
# Description: Guess
# Author: Zhichun Li
# Northwestern Systems Research Group
# Department of Computer Science
# Northwestern University
# Language: Makefile
# Package: N/A
# Status: Experimental (Do Not Distribute)
#
# (C) Copyright 2006, Northwestern University, all rights reserved.
#
###############################################################################
CXX = g++
MV = mv
CP = cp
RM = rm
MKDIR = mkdir
TAR = tar cvf
COMPRESS = gzip
INC = $(shell pkg-config --cflags sary)
#CXXFLAGS = -Wall -ggdb -c ${INC}
CXXFLAGS = -Wall -O3 -c ${INC}
LIBS = -lm $(shell pkg-config --libs sary) -LTokenEXAPI -ltkex -lds_ssort -lbwtlcp
TARGET = test_tracesary
TARGET = siggen
STATICLIBS =
SOURCES = test_tracesary.cpp tracesary.cpp utils.cpp
SOURCES = siggen_main.cpp tracesary.cpp utils.cpp tokenExtract.cpp conjpattern.cpp sig_gen.cpp
SOURCES = tracesary.cpp utils.cpp tokenExtract.cpp conjpattern.cpp sig_gen.cpp
HEADER = utils.h tracesary.h bitvec.h globals.h
OBJS = ${SOURCES:.cpp=.o}
all: ${TARGET} siggen_nonoise
#utils.o: utils.cpp ${HEADER}
# ${CXX} ${CXXFLAGS} $<
#tracesary.o: tracesary.cpp ${HEADER}
# ${CXX} ${CXXFLAGS} $<
#test_tracesary.o: test_tracesary.cpp ${HEADER}
# ${CXX} ${CXXFLAGS} $<
#siggen.o: sigen.cpp ${HEADER}
# ${CXX} ${CXXFLAGS} $<
${TARGET}: siggen_main.o ${OBJS}
${CXX} -o $# ${OBJS} siggen_main.o ${LIBS}
siggen_nonoise: siggen_nonoise.o ${OBJS}
${CXX} -o $# ${OBJS} siggen_nonoise.o ${LIBS}
%.o: %.cpp *.h
$(CXX) $(CXXFLAGS) -c $< -o $#
clean:
${RM} -f *.o *~ ${TARGET} siggen_nonoise
cleanAll: clean
and I also tried it with
$(shell pkg-config --libs glib-2.0)
with no effect

collect2: ld returned 1 exit status compiling error

After trying to compile a program on a friendlyARM qtopia 2.0.0 but I am getting this error:
/sdcard/images/makef # make -f Makefile
gcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt
/usr/bin/ld:/usr/lib/gcc/arm-linux-gnueabi/4.4.1/../../../librt.so: file format not recognized; treating as linker script
/usr/bin/ld:/usr/lib/gcc/arm-linux-gnueabi/4.4.1/../../../librt.so:2: syntax error
collect2: ld returned 1 exit status
make: *** [main] Error 1
/sdcard/images/makef #
makefile :
IDIR =./
CC=gcc
CFLAGS=-I$(IDIR)
ODIR=obj
LDIR =./
LIBS=-lgd -lrt
_DEPS = main.h Makefile
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = main.o serial.o fb.o menu_main.o timer.o cmdin.o buzzer.o statemachine.o inout.o network.o text_file_input.o text_file_input_oven.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $# $< $(CFLAGS)
main: $(OBJ)
gcc -o $# $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~