Program does not link to library even adding content of "pkg-config --libs" to $CFLAGS or $LDFLAGS - makefile

I am trying to compile a program which depends upon GLib's libgthread. The library is installed in my machine (Ubuntu 12.04) and pkg-config finds it:
$ pkg-config --libs gthread-2.0
-pthread -lgthread-2.0 -lrt -lglib-2.0
I tried to run configure setting $CFLAGS with such output:
$ CFLAGS=`pkg-config --libs gthread-2.0` ./configure
but it did not work:
$ make
[...]
gcc -g -O2 -I/include -I/home/adam/fs//include -I/usr/include/libxml2 -pthread -lgthread-2.0 -lrt -lglib-2.0 -o ama [...] -lxml2
ama-ama.o: In function `main':
/home/adam/software/ama/src/ama.c:89: undefined reference to `g_thread_init'
collect2: ld returned 1 exit status
make[2]: ** [ama] Erro 1
make[2]: Saindo do diretório `/home/adam/software/ama/src'
make[1]: ** [all-recursive] Erro 1
make[1]: Saindo do diretório `/home/adam/software/ama'
make: ** [all] Erro 2
I tried to set $LDFLAGS, too:
$ LDFLAGS=`pkg-config --libs gthread-2.0` ./configure
and got the same error.
What should I do?

The correct variable to set is $LIBS:
$ LIBS=`pkg-config --libs gthread-2.0` ./configure

Related

Raylib Makefile Issue

I've install raylib according to this wiki page.
My Project Folder is look like this:
[this][1]
> ..\build>mingw32-make
g++ ../main.cpp -o test.exe -O2 -Wall -Wno-missing-braces -I ../include/ -L ../lib/ -lraylib -lopeng132 -lgdi32 -lwinmm
D:/Software/raylib/mingw/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lopeng132
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [Makefile:2: default] Error 1```
[1]: https://i.stack.imgur.com/QK2X3.png
It seems you have typed openg132 instead of opengl132. You have mistaken the letter l for the number 1

How to remove a link option from ld in make file?

I'm installing a ROOT class and I ran into an error.
caffeinated:libroot-hijing-1.7 sudoankit$ make
/bin/sh ../libtool --tag=CXX --mode=link /usr/bin/g++ -std=gnu++11 -g -O2 -L/usr/local/Cellar/root6/6.06.08/lib/root -R /usr/local/Cellar/root6/6.06.08/lib/root -version-info 1:7:0 -o libTHijing.la -rpath /Users/sudoankit/lib THijing.lo THijingMinBias.lo THijingFlow.lo THijingPara.lo TRanMar.lo ran.lo hijing1.383.lo hipyset1.35.lo THijingDict.lo -lCint -lCore -lTree -lPhysics -lGraf3d -lGraf -lHist -lMatrix -lEG -L/usr/local/Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin16.0.0/6.2.0 -L/usr/local/Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin16.0.0/6.2.0/../../.. -lgfortran -lquadmath -lm
libtool: link: /usr/bin/g++ -std=gnu++11 -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libTHijing.1.dylib .libs/THijing.o .libs/THijingMinBias.o .libs/THijingFlow.o .libs/THijingPara.o .libs/TRanMar.o .libs/ran.o .libs/hijing1.383.o .libs/hipyset1.35.o .libs/THijingDict.o -L/usr/local/Cellar/root6/6.06.08/lib/root -lCint -lCore -lTree -lPhysics -lGraf3d -lGraf -lHist -lMatrix -lEG -L/usr/local/Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin16.0.0/6.2.0 -L/usr/local/Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin16.0.0/6.2.0/../../.. -lgfortran -lquadmath -lm -g -O2 -install_name /Users/sudoankit/lib/libTHijing.1.dylib -compatibility_version 2 -current_version 2.7 -Wl,-single_module
ld: library not found for -lCint
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libTHijing.la] Error 1
make: *** [all-recursive] Error 1
The solution I found after some time is to remove the -lCint library from ld. How should I do this? Where is the linking located in the Makefile? Or the configure file?
An example of filter-out:
A = X Y -lCint Z
B = $(filter-out -lCint, $(A))
all:
#echo $(B)

'glib.h' file not found on Max OSX 10.9

I'm trying to compile msg2pdf which is a tool to convert messages in mu4e (mu for Emacs) to pdf.
I'm receiving the following error :
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in .
CC msg2pdf.o
In file included from msg2pdf.c:20:
In file included from ../../lib/mu-msg.h:24:
../../lib/mu-flags.h:24:10: fatal error: 'glib.h' file not found
#include <glib.h>
^
1 error generated.
make[2]: *** [msg2pdf.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Oddly, I checked the Makefile and GLIB_CFLAGS seem to be pointing on the right folder (where brew installed it).
In fact, glib.h is located in /usr/local/Cellar/glib/2.40.0_1/include/glib-2.0.
GLIB_CFLAGS = -D_REENTRANT -I/usr/local/Cellar/glib/2.40.0_1/include/glib-2.0 -I/usr/local/Cellar/glib/2.40.0_1/lib/glib-2.0/include -I/usr/local/opt/gettext/include
GLIB_LIBS = -L/usr/local/Cellar/glib/2.40.0_1/lib -L/usr/local/opt/gettext/lib -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
How can I succeed compiling the file? Is there any command line "hack" I can use while calling
make?
Edit
Here are the files in the directory
https://github.com/flexdec/temp
Edit 2
This is the output when using make V=1
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in .
gcc -DHAVE_CONFIG_H -I. -I../.. -I../../lib -DICONDIR='""' -Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement -g -O2 -MT msg2pdf.o -MD -MP -MF .deps/msg2pdf.Tpo -c -o msg2pdf.o msg2pdf.c
In file included from msg2pdf.c:20:
In file included from ../../lib/mu-msg.h:24:
../../lib/mu-flags.h:24:10: fatal error: 'glib.h' file not found
#include <glib.h>
^
1 error generated.
make[2]: *** [msg2pdf.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Edit 3
The new error I get using make V=1 now that GLIB_CFLAGS issue is fixed
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in .
gcc -DHAVE_CONFIG_H -I. -I../.. -I../../lib -D_REENTRANT -I/usr/local/Cellar/glib/2.40.0_1/include/glib-2.0 -I/usr/local/Cellar/glib/2.40.0_1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -DICONDIR='""' -Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement -g -O2 -MT msg2pdf.o -MD -MP -MF .deps/msg2pdf.Tpo -c -o msg2pdf.o msg2pdf.c
msg2pdf.c:24:10: fatal error: 'gtk/gtk.h' file not found
#include <gtk/gtk.h>
^
1 error generated.
make[2]: *** [msg2pdf.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
make V=1 instead of make will tell you what the C compiler command looks like (instead of just "CC msg2pdf.o")—check that and make sure it includes the flags you need.
Based on a quick look at your Makefile.am, you are including $(GTK_CFLAGS) and $(WEBKIT_CFLAGS) in your AM_CPPFLAGS but not $(GLIB_CFLAGS).
You need to run ./configure in mu's top-level directory on the machine where you want to compile it. configure will tell you about any missing dependencies. Optional components (such as msg2pdf) are skipped if their dependencies are not there.
Then, after configure succeeds, do a 'make'.
In any case, if configure has run successfully, the top-level 'make' should succeed as well (that's why we have configure!), otherwise please file a bug.

make[ ]: *** [ ] Error 1

I am trying to compile a file on gcc and my 'make' command seems to throw an error.
Rishabhs-MacBook-Pro:binutils-2.20.1 Rishabh$ make
make[3]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all'.
Making info in doc
make chew
make[4]: `chew' is up to date.
./chew -f ./doc.str <./../opncls.c >opncls.tmp
/bin/sh ./../../move-if-change opncls.tmp opncls.texi
Making info in po
...
...
make[4]: Nothing to be done for `all'.
gcc -DHAVE_CONFIG_H -I. -I. -I. -I../bfd -I./../bfd -I./../include - DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror -g -O2 -MT strings.o -MD -MP -MF .deps/strings.Tpo -c -o strings.o strings.c
cc1: warnings being treated as errors
strings.c: In function ‘strings_file’:
strings.c:419: warning: ‘stat64’ is deprecated (declared at /usr/include/sys/stat.h:466)
make[4]: *** [strings.o] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-binutils] Error 2
make: *** [all] Error 2
I think the problem could be with the gcc but I can't seem to get around the problem. Any help would be appreciated.
You have the -Werror flag on the gcc command line. As the output says:
cc1: warnings being treated as errors
So either change your makefile not to include this or fix the stat64 is deprecated warning in strings.c!

Building Lua 5.0 on 64bit Mac

For compatibility/legacy reasons I need to build the Lua compiler (luac) from version 5.0, on my 64bit Intel Mac. (5.1 or later can't be used.)
Dev tools installed through Xcode 4.6's Preferences window.
After I 'cd' in to the Lua directory, I issue the command 'make'.
cd include; make all
make[1]: Nothing to be done for `all'.
cd src; make all
make[1]: Nothing to be done for `all'.
cd src/lib; make all
make[1]: Nothing to be done for `all'.
cd src/luac; make all
gcc -o ../../bin/luac luac.o print.o lopcodes.o -L../../lib -llua -llualib -lm
Undefined symbols for architecture x86_64:
"_UNUSED", referenced from:
_writer in luac.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [../../bin/luac] Error 1
make: *** [all] Error 2
I do not know how to configure the make process for x86_64. Could someone please step me through it?
Thanks.
It works for me, but the output below is different from yours:
...
cd src/luac; make all
gcc -O2 -Wall -I../../include -I.. -c -o luac.o luac.c
gcc -O2 -Wall -I../../include -I.. -c -o print.o print.c
gcc -o lopcodes.o -c -O2 -Wall -I../../include -I.. -DLUA_OPNAMES ../lopcodes.c
gcc -o ../../bin/luac luac.o print.o lopcodes.o -L../../lib -llua -llualib -lm
cd src/lua; make all
gcc -O2 -Wall -I../../include -c -o lua.o lua.c
Try make clean all at the top level first.

Resources