Installing tree-1.6.0 in cygwin. What am I missing? - installation

I am trying to install tree 1.6.0 in my cygwin console. To do that, I downloaded the source.
Here is the content of the file
===> ls -lh
total 269K
-rw-r--r-- 1 user None 8.8K Jun 24 2011 CHANGES
-rw-r--r-- 1 user None 16K Jun 22 2011 color.c
-rw-r--r-- 1 user None 17K Apr 14 11:35 color.o
drwxr-xr-x+ 1 user None 0 Apr 14 11:35 doc
-rw-r--r-- 1 user None 3.1K Jun 24 2011 hash.c
-rw-r--r-- 1 user None 2.4K Apr 14 11:35 hash.o
-rw-r--r-- 1 user None 15K Jun 24 2011 html.c
-rw-r--r-- 1 user None 21K Apr 14 11:35 html.o
-rw-r--r-- 1 user None 596 Jun 24 2011 INSTALL
-rw-r--r-- 1 user None 18K Aug 12 2004 LICENSE
-rw-r--r-- 1 user None 2.6K Jun 24 2011 Makefile
-rw-r--r-- 1 user None 4.6K Jun 24 2011 README
-rw-r--r-- 1 user None 5.2K Aug 27 2008 strverscmp.c
-rw-r--r-- 1 user None 2.2K Jun 24 2011 TODO
-rw-r--r-- 1 user None 31K Jun 24 2011 tree.c
-rw-r--r-- 1 user None 5.0K Jun 24 2011 tree.h
-rw-r--r-- 1 user None 37K Apr 14 11:35 tree.o
-rw-r--r-- 1 user None 7.4K Jun 22 2011 unix.c
-rw-r--r-- 1 user None 11K Apr 14 11:35 unix.o
-rw-r--r-- 1 user None 8.7K Jun 24 2011 xml.c
-rw-r--r-- 1 user None 13K Apr 14 11:35 xml.o
When I run make, the following is what I get:
===> make
gcc -O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o tree.o tree.c
tree.c: In function ‘main’:
tree.c:481:7: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘off_t’ [-Wformat=]
if (duflag) fprintf(outfile," <size>%lld</size>\n", size);
^
tree.c:481:7: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘off_t’ [-Wformat=]
tree.c: In function ‘versort’:
tree.c:782:5: warning: implicit declaration of function ‘strverscmp’ [-Wimplicit-function-declaration]
if ((*a)->isdir == (*b)->isdir) return strverscmp((*a)->name,(*b)->name);
^
tree.c: In function ‘psize’:
tree.c:1107:3: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘off_t’ [-Wformat=]
} else return sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9ld", size);
^
tree.c:1107:3: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘off_t’ [-Wformat=]
gcc -O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o unix.o unix.c
gcc -O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o html.o html.c
gcc -O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o xml.o xml.c
xml.c: In function ‘xml_fillinfo’:
xml.c:301:3: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘ off_t’ [-Wformat=]
if (sflag) fprintf(outfile, " size=\"%lld\"", ent->size);
^
xml.c:301:3: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘ off_t’ [-Wformat=]
gcc -O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o hash.o hash.c
gcc -O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o color.o color.c
gcc -s -o tree tree.o unix.o html.o xml.o hash.o color.o
tree.o:tree.c:(.text+0x1ba): undefined reference to `strverscmp'
tree.o:tree.c:(.text+0x1ba): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `strve rscmp'
/usr/bin/ld: tree.o: bad reloc address 0x0 in section `.data'
/usr/bin/ld: final link failed: Invalid operation
collect2: error: ld returned 1 exit status
Makefile:86: recipe for target 'tree' failed
make: *** [tree] Error 1
What is wrong and how can I fix this?

You should follow the instructions in the document INSTALL, in the top level of the distribution directory. In particular the first step:
1. Edit the Makefile for your OS.

Related

Not able to compile with gcc using -m32

amar#pc:/local/mnt/workspace/amarn$ gcc -m32 a.c
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
amar#pc:/local/mnt/workspace/amarn$ cat a.c
#include <stdio.h>
int
main ()
{
long z;
printf("Long int size is %d bytes long!\n", sizeof(z));
;
return 0;
}
amarn#hyd-tbsbld01:/local/mnt/workspace/amarn$ uname -a
Linux mypc 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
I made following change for gcc.
gcc was mapped to gcc-5.
I mapped gcc to gcc-4.8.
amar#mypc:/usr/bin$ ll | grep gcc
-rwxr-xr-x 1 root root 428 May 7 2006 c89-gcc
-rwxr-xr-x 1 root root 454 Apr 11 2011 c99-gcc
lrwxrwxrwx 1 root root 7 Jun 1 11:54 gcc -> gcc-4.8
-rwxr-xr-x 1 root root 776344 Jan 26 2016 gcc-4.8
-rwxr-xr-x 1 root root 915736 Nov 3 2016 gcc-5
lrwxrwxrwx 1 root root 10 Jun 1 11:55 gcc-ar -> gcc-ar-4.8
-rwxr-xr-x 1 root root 27032 Jan 26 2016 gcc-ar-4.8
-rwxr-xr-x 1 root root 31136 Nov 3 2016 gcc-ar-5
lrwxrwxrwx 1 root root 10 Jun 1 11:56 gcc-nm -> gcc-nm-4.8
-rwxr-xr-x 1 root root 27032 Jan 26 2016 gcc-nm-4.8
-rwxr-xr-x 1 root root 31136 Nov 3 2016 gcc-nm-5
lrwxrwxrwx 1 root root 14 Jun 1 11:56 gcc-ranlib -> gcc-ranlib-4.8
-rwxr-xr-x 1 root root 27032 Jan 26 2016 gcc-ranlib-4.8
-rwxr-xr-x 1 root root 31136 Nov 3 2016 gcc-ranlib-5
lrwxrwxrwx 1 root root 7 Jun 1 12:32 x86_64-linux-gnu-gcc -> gcc-4.8
lrwxrwxrwx 1 root root 7 Jan 26 2016 x86_64-linux-gnu-gcc-4.8 -> gcc-4.8
lrwxrwxrwx 1 root root 5 Nov 3 2016 x86_64-linux-gnu-gcc-5 -> gcc-5
lrwxrwxrwx 1 root root 10 Jun 1 12:34 x86_64-linux-gnu-gcc-ar -> gcc-ar-4.8
lrwxrwxrwx 1 root root 10 Jan 26 2016 x86_64-linux-gnu-gcc-ar-4.8 -> gcc-ar-4.8
lrwxrwxrwx 1 root root 8 Nov 3 2016 x86_64-linux-gnu-gcc-ar-5 -> gcc-ar-5
lrwxrwxrwx 1 root root 10 Jun 1 12:34 x86_64-linux-gnu-gcc-nm -> gcc-nm-4.8
lrwxrwxrwx 1 root root 10 Jan 26 2016 x86_64-linux-gnu-gcc-nm-4.8 -> gcc-nm-4.8
lrwxrwxrwx 1 root root 8 Nov 3 2016 x86_64-linux-gnu-gcc-nm-5 -> gcc-nm-5
lrwxrwxrwx 1 root root 14 Jun 1 12:35 x86_64-linux-gnu-gcc-ranlib -> gcc-ranlib-4.8
lrwxrwxrwx 1 root root 14 Jan 26 2016 x86_64-linux-gnu-gcc-ranlib-4.8 -> gcc-ranlib-4.8
lrwxrwxrwx 1 root root 12 Nov 3 2016 x86_64-linux-gnu-gcc-ranlib-5 -> gcc-ranlib-5

Compiling gstreamer with new glib version

I have CentOS 6.7 installed. I need to compile GStreamer 1.4.5 (or any 1.x) because CentOS distribution has GStreamer 0.10. GStreamer 1.x requires GLib2 >= 2.32 or so, but CentOS has 2.28.8. Therefore I compiled GLib 2.44.1 using specific location /usr/mylibs (as --prefix param).
ll /usr/mylibs/lib
total 26008
drwxr-xr-x. 3 root root 4096 Sep 3 16:48 gio
drwxr-xr-x. 3 root root 4096 Sep 3 16:48 glib-2.0
drwxr-xr-x. 3 root root 4096 Sep 3 15:44 libffi-3.2.1
-rwxr-xr-x. 1 root root 1132 Sep 3 16:48 libgio-2.0.la
lrwxrwxrwx. 1 root root 22 Sep 3 16:48 libgio-2.0.so -> libgio-2.0.so.0.4400.1
lrwxrwxrwx. 1 root root 22 Sep 3 16:48 libgio-2.0.so.0 -> libgio-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 6208700 Sep 3 16:48 libgio-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 1005 Sep 3 16:48 libglib-2.0.la
lrwxrwxrwx. 1 root root 23 Sep 3 16:48 libglib-2.0.so -> libglib-2.0.so.0.4400.1
lrwxrwxrwx. 1 root root 23 Sep 3 16:48 libglib-2.0.so.0 -> libglib-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 3172134 Sep 3 16:48 libglib-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 1059 Sep 3 16:48 libgmodule-2.0.la
lrwxrwxrwx. 1 root root 26 Sep 3 16:48 libgmodule-2.0.so -> libgmodule-2.0.so.0.4400.1
lrwxrwxrwx. 1 root root 26 Sep 3 16:48 libgmodule-2.0.so.0 -> libgmodule-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 39251 Sep 3 16:48 libgmodule-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 1060 Sep 3 16:48 libgobject-2.0.la
lrwxrwxrwx. 1 root root 26 Sep 3 16:48 libgobject-2.0.so -> libgobject-2.0.so.0.4400.1
lrwxrwxrwx. 1 root root 26 Sep 3 16:48 libgobject-2.0.so.0 -> libgobject-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 1188762 Sep 3 16:48 libgobject-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 1054 Sep 3 16:48 libgthread-2.0.la
lrwxrwxrwx. 1 root root 26 Sep 3 16:48 libgthread-2.0.so -> libgthread-2.0.so.0.4400.1
lrwxrwxrwx. 1 root root 26 Sep 3 16:48 libgthread-2.0.so.0 -> libgthread-2.0.so.0.4400.1
-rwxr-xr-x. 1 root root 9001 Sep 3 16:48 libgthread-2.0.so.0.4400.1
-rw-r--r--. 1 root root 921042 Sep 3 16:15 libpcre16.a
-rwxr-xr-x. 1 root root 931 Sep 3 16:15 libpcre16.la
lrwxrwxrwx. 1 root root 18 Sep 3 16:15 libpcre16.so -> libpcre16.so.0.2.5
lrwxrwxrwx. 1 root root 18 Sep 3 16:15 libpcre16.so.0 -> libpcre16.so.0.2.5
-rwxr-xr-x. 1 root root 618161 Sep 3 16:15 libpcre16.so.0.2.5
-rw-r--r--. 1 root root 893956 Sep 3 16:15 libpcre32.a
-rwxr-xr-x. 1 root root 931 Sep 3 16:15 libpcre32.la
lrwxrwxrwx. 1 root root 18 Sep 3 16:15 libpcre32.so -> libpcre32.so.0.0.5
lrwxrwxrwx. 1 root root 18 Sep 3 16:15 libpcre32.so.0 -> libpcre32.so.0.0.5
-rwxr-xr-x. 1 root root 593479 Sep 3 16:15 libpcre32.so.0.0.5
-rw-r--r--. 1 root root 975726 Sep 3 16:15 libpcre.a
-rw-r--r--. 1 root root 46462 Sep 3 16:15 libpcrecpp.a
-rwxr-xr-x. 1 root root 965 Sep 3 16:15 libpcrecpp.la
lrwxrwxrwx. 1 root root 19 Sep 3 16:15 libpcrecpp.so -> libpcrecpp.so.0.0.1
lrwxrwxrwx. 1 root root 19 Sep 3 16:15 libpcrecpp.so.0 -> libpcrecpp.so.0.0.1
-rwxr-xr-x. 1 root root 43351 Sep 3 16:15 libpcrecpp.so.0.0.1
-rwxr-xr-x. 1 root root 917 Sep 3 16:15 libpcre.la
-rw-r--r--. 1 root root 21720 Sep 3 16:15 libpcreposix.a
-rwxr-xr-x. 1 root root 979 Sep 3 16:15 libpcreposix.la
lrwxrwxrwx. 1 root root 21 Sep 3 16:15 libpcreposix.so -> libpcreposix.so.0.0.3
lrwxrwxrwx. 1 root root 21 Sep 3 16:15 libpcreposix.so.0 -> libpcreposix.so.0.0.3
-rwxr-xr-x. 1 root root 18917 Sep 3 16:15 libpcreposix.so.0.0.3
lrwxrwxrwx. 1 root root 21 Sep 3 16:43 libpcre.so -> /lib/libpcre.so.1.2.5
-rwxr-xr-x. 1 root root 693207 Sep 3 16:47 libpcre.so.1
-rwxr-xr-x. 1 root root 693207 Sep 3 16:47 libpcre.so.1.2.5
-rwxr-xr-x. 1 root root 10381922 Sep 3 16:00 libpython2.7.a
drwxr-xr-x. 2 root root 4096 Sep 3 16:48 pkgconfig
drwxr-xr-x. 28 root root 20480 Sep 3 16:03 python2.7
Now I'm trying to compile GStreamer 1.4.5:
export GLIB_CFLAGS="-I/usr/mylibs/include/glib-2.0 -I/usr/mylibs/lib/glib-2.0/include" && export GLIB_LIBS="-L/usr/mylibs -L/usr/mylibs/lib/glib-2.0" && export GIO_CFLAGS="-I/usr/mylibs/include -I/usr/mylibs/include/gio-unix-2.0" && export GIO_LIBS="-L/usr/mylibs -L/usr/mylibs/lib/gio" && export PYTHON=/usr/mylibs/bin/python
./configure --prefix=/usr/mylib
or
./configure
make
And it works until this error:
Making all in helpers
make[4]: Entering directory `/root/gstreamer/gstreamer-1.4.5/libs/gst/helpers'
CC gst_plugin_scanner-gst-plugin-scanner.o
CCLD gst-plugin-scanner
gst_plugin_scanner-gst-plugin-scanner.o: In function `main':
/root/gstreamer/gstreamer-1.4.5/libs/gst/helpers/gst-plugin-scanner.c:45: undefined reference to `g_malloc'
/root/gstreamer/gstreamer-1.4.5/libs/gst/helpers/gst-plugin-scanner.c:55: undefined reference to `g_free'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_param_spec_object'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_utf8_validate'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_date_get_month'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_value_get_float'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_checksum_update'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_memdup'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_type_interface_peek'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_value_set_int64'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_thread_pool_new'
...
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_param_spec_ref'
collect2: ld returned 1 exit status
make[4]: *** [gst-plugin-scanner] Error 1
make[4]: Leaving directory `/root/gstreamer/gstreamer-1.4.5/libs/gst/helpers'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/root/gstreamer/gstreamer-1.4.5/libs/gst'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/gstreamer/gstreamer-1.4.5/libs'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/gstreamer/gstreamer-1.4.5'
make: *** [all] Error 2
What have I missed? Please help.
I encountered the same problem on my CentOS 6.3 VM. I was attempting to build GStreamer 1.4.5 against glib 2.32.4. As shown in this message thread it would appear that the incorrect libraries are being linked when you attempt to build (not the 2.0 ones!) Rather than explicitly defining the directory paths in GLIB_CFLAGS you could use PKG_CONFIG_PATH.
Locate the pkgconfig directory and ensure packages you have installed reside in there (like glib-2.0, gobject-2.0, gthread-2.0, etc.) (On my computer my path was: /usr/local/lib/pkconfig/.) I noticed in your directory listing that you have provided you do indeed have pkgconfig.
First, export the variable, then configure, and finally make:
export PKG_CONFIG_PATH=/usr/mylibs/lib/pkgconfig/
./configure
make
GStreamer should now build correctly.
You seem to be misunderstanding how the *_LIBS environment variable works. It should contain the flags needed to link to glib; something like "-L/usr/mylibs/lib -lglib-2.0" should work.
The -L… flag gives the linker an additional place to look for shared libraries (i.e., libglib-2.0.so), but in your flags you've given it one directory above what it needs (/usr/mylibs) and a subdirectory (/usr/mylibs/lib/glib-2.0). The -l… flag tells it what specific library to look for, but you completely omitted it.

When I include a static library "libupnpx.a" in my project that is 6 MB, does this make my app 6 MB larger?

I have heard the compiler strips out unused code. But when I include a libupnpx.a static library archive of 6 MB, will this make app 6 MB larger? Or is this same as including the library source code directly?
The answer is not as simple as you may think:
Let's do an experiment:
We will create a libfoo.a with the following structure:
Makefile:
LIBOUT=libfoo.a
SRC=foo1.c foo2.c foo3.c
OBJ=$(SRC:%.c=%.o)
default: test1 test2 test3
test1: $(LIBOUT)
$(CC) -o $# test1.c -L. -lfoo
test2: $(LIBOUT)
$(CC) -o $# test2.c -L. -lfoo
test3: $(LIBOUT)
$(CC) -o $# test3.c -L. -lfoo
$(LIBOUT): $(OBJ)
$(AR) ruv $(LIBOUT) $(OBJ)
foo1.c:
#include <stdio.h>
int foo1_service_a() {
printf("Performing foo1_service_a\n");
return 0;
}
foo2.c:
#include <stdio.h>
int foo2_service_a() {
printf("Performing foo2_service_a\n");
return 0;
}
foo3.c:
#include <stdio.h>
int foo3_service_a() {
printf("Performing foo3_service_a\n");
return 0;
}
int foo3_service_b() {
printf("Performing foo3_service_b\n");
return 0;
}
And three test programs:
test1.c:
int main() {
foo1_service_a();
return 0;
}
test2.c:
int main() {
foo2_service_a();
return 0;
}
test3.c:
int main() {
foo3_service_a();
return 0;
}
When we compile them we get:
-rw-r--r-- 1 masud users 285 Aug 3 16:42 Makefile
-rw-r--r-- 1 masud users 96 Aug 3 16:38 foo1.c
-rw-r--r-- 1 masud users 1496 Aug 3 16:39 foo1.o
-rw-r--r-- 1 masud users 97 Aug 3 16:39 foo2.c
-rw-r--r-- 1 masud users 1496 Aug 3 16:39 foo2.o
-rw-r--r-- 1 masud users 173 Aug 3 16:39 foo3.c
-rw-r--r-- 1 masud users 1688 Aug 3 16:40 foo3.o
-rw-r--r-- 1 masud users 5008 Aug 3 16:40 libfoo.a
-rwxr-xr-x 1 masud users 9132 Aug 3 16:43 test1
-rw-r--r-- 1 masud users 45 Aug 3 16:43 test1.c
-rwxr-xr-x 1 masud users 9132 Aug 3 16:43 test2
-rw-r--r-- 1 masud users 45 Aug 3 16:43 test2.c
-rwxr-xr-x 1 masud users 9251 Aug 3 16:43 test3
-rw-r--r-- 1 masud users 45 Aug 3 16:43 test3.c
As you can tell that each of test1 test2 and test3 have foo1.o; foo2.o and foo3.o dictating their end sizes.
So it's the archive's content division that determines the size of the end binary.
Exercise for the reader
What happens to the sizes when you strip the binaries? do test1 test2 and test3 become the same size?
Why or why not ? :)
You can generally expect that static linking and "including the library source code directly" will have equivalent impacts on the size of the resulting executable. There are be some minor cases in which this may not be strictly true, but generally speaking, they should be approximately equivalent.

g++ and boost linker error on Ubuntu oneiric

I am getting the following errors after an upgrade. I cannot figure what is wrong with it. It should work as far as I can see.
$ make 2>&1 | head
g++ -o prog -ansi -O2 -Wall -I/usr/include/boost -L/usr/lib -lboost_program_options -lboost_thread -lstdc++ ./YYY.o ./main.o ./myClass.o
./YYY.o: In function `void boost::call_once<void (*)()>(boost::once_flag&, void (*)())':
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x14): undefined reference to `boost::detail::get_once_per_thread_epoch()'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x2c): undefined reference to `boost::detail::once_epoch_mutex'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x62): undefined reference to `boost::detail::once_epoch_mutex'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x67): undefined reference to `boost::detail::once_epoch_cv'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x95): undefined reference to `boost::detail::once_epoch_mutex'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0xa9): undefined reference to `boost::detail::once_epoch_mutex'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0xbd): undefined reference to `boost::detail::once_global_epoch'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0xc2): undefined reference to `boost::detail::once_epoch_cv'
$ ls -l /usr/lib/*boost_threa*
0 lrwxrwxrwx 1 root root 17 Jun 3 22:30 /usr/lib/libboost_thread-mt.a -> libboost_thread.a
0 lrwxrwxrwx 1 root root 25 Jun 3 22:30 /usr/lib/libboost_thread-mt.so -> libboost_thread.so.1.46.1
208K -rw-r--r-- 1 root root 208K Jun 3 22:30 /usr/lib/libboost_thread.a
0 lrwxrwxrwx 1 root root 25 Jun 3 22:30 /usr/lib/libboost_thread.so -> libboost_thread.so.1.46.1
88K -rw-r--r-- 1 root root 87K Oct 21 2010 /usr/lib/libboost_thread.so.1.42.0
100K -rw-r--r-- 1 root root 99K Jun 3 22:30 /usr/lib/libboost_thread.so.1.46.1
$ ls -ld /usr/include/boost/*thread*
4.0K drwxr-xr-x 5 root root 4.0K Oct 13 21:59 /usr/include/boost/thread/
4.0K -rw-r--r-- 1 root root 839 Jun 3 22:18 /usr/include/boost/thread.hpp
The solution involved changing the order of linkage, as per the man page. The thing is that it used to work fine with an older version of g++...
$ make
g++ -I/usr/include/boost -MM ./YYY.cc ./main.cc ./myClass.cc > buildfiles.d
g++ -ansi -O2 -Wall -I/usr/include/boost -c -o main.o main.cc
g++ -ansi -O2 -Wall -I/usr/include/boost -c -o myClass.o myClass.cc
g++ -o prog -ansi -O2 -Wall -I/usr/include/boost ./YYY.o ./main.o ./myClass.o -lstdc++ -L/usr/lib -lboost_program_options -lboost_thread

How to build a source code tree using multiple Makefiles

FYI: all work can be seen in the trac repo # http://matthewh.me/scripts/browser/c/shared_library?order=name
The original post was to long. It essentially asked why my Makefiles were not finding any of the source when building from the root directory.
UPDATE:
I did discover that the paths are all relative to the root directory, regardless of where the makefiles are placed.
I have the libs building now, however I am getting an undefined reference to main when compiling the app.
I will not paste the updated makefiles, but the source tree now looks like:
mehoggan#mehoggan-laptop:~/Code/shared_library$ make
gcc -c -o ./c_lib/c_lib.o ./c_lib/c_lib.c
rm -f ./c_lib/libClib.so.1.0.0 ./c_lib/libClib.so ./c_lib/libClib.so.1 ./c_lib/libClib.so.1.0
gcc -m32 -Wl,-O1 -shared -o ./c_lib/libClib.so.1.0.0 -lpthread
ln -s ./libClib.so.1.0.0 ./c_lib/libClib.so
ln -s ./libClib.so.1.0.0 ./c_lib/libClib.so.1
ln -s ./libClib.so.1.0.0 ./c_lib/libClib.so.1.0
rm -f ./c_lib/libClib.a
ar cqs ./c_lib/libClib.a ./c_lib/c_lib.o
cc -c -m32 -pipe -O2 -Wall -W -D_REENTRANT -I./c_lib/ -o ./app/main.o ./app/main.c
gcc -m32 -Wl,-O1 -o ./app/main.o -L./c_lib/ -lClib
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [app/main] Error 1
mehoggan#mehoggan-laptop:~/Code/shared_library$ ls -lR
.:
total 12
drwxr-xr-x 2 mehoggan mehoggan 4096 2011-11-20 20:23 app
drwxr-xr-x 2 mehoggan mehoggan 4096 2011-11-20 20:23 c_lib
-rw-r--r-- 1 mehoggan mehoggan 824 2011-11-20 19:50 Makefile
./app:
total 8
-rw-r--r-- 1 mehoggan mehoggan 291 2011-11-20 18:52 main.c
-rw-r--r-- 1 mehoggan mehoggan 503 2011-11-20 20:23 Makefile
./c_lib:
total 28
-rw-r--r-- 1 mehoggan mehoggan 245 2011-11-20 18:54 c_lib.c
-rw-r--r-- 1 mehoggan mehoggan 46 2011-11-20 19:53 c_lib.h
-rw-r--r-- 1 mehoggan mehoggan 864 2011-11-20 20:23 c_lib.o
-rw-r--r-- 1 mehoggan mehoggan 1008 2011-11-20 20:23 libClib.a
lrwxrwxrwx 1 mehoggan mehoggan 18 2011-11-20 20:23 libClib.so -> ./libClib.so.1.0.0
lrwxrwxrwx 1 mehoggan mehoggan 18 2011-11-20 20:23 libClib.so.1 -> ./libClib.so.1.0.0
lrwxrwxrwx 1 mehoggan mehoggan 18 2011-11-20 20:23 libClib.so.1.0 -> ./libClib.so.1.0.0
-rwxr-xr-x 1 mehoggan mehoggan 6588 2011-11-20 20:23 libClib.so.1.0.0
-rw-r--r-- 1 mehoggan mehoggan 930 2011-11-20 20:20 Makefile
The contents of main.c are:
#include <stdio.h>
#include "c_lib.h"
int main(int argc, char *argv[])
{
if (argc > 1) {
char *arg = argv[1];
printf("%s\n", arg);
}
char str[12] = "hello world\0";
printf("%s\n", str);
char *rev = reverse(str);
printf("%s\n", rev);
return 1;
}
Why can the compiler not find the main function?
UPDATE
Your fix helped get pass the undefined reference to main, however I am now getting another undefined reference:
[mehoggan#hogganz400 shared_library]$ make
gcc -c -m32 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -I. -o ./c_lib/c_lib.o ./c_lib/c_lib.c
rm -f ./c_lib/libClib.so.1.0.0 ./c_lib/libClib.so ./c_lib/libClib.so.1 ./c_lib/libClib.so.1.0
gcc -m32 -Wl,-O1 -shared -o ./c_lib/libClib.so.1.0.0 -lpthread
ln -s ./libClib.so.1.0.0 ./c_lib/libClib.so
ln -s ./libClib.so.1.0.0 ./c_lib/libClib.so.1
ln -s ./libClib.so.1.0.0 ./c_lib/libClib.so.1.0
rm -f ./c_lib/libClib.a
ar cqs ./c_lib/libClib.a ./c_lib/c_lib.o
gcc -c -m32 -pipe -O2 -Wall -W -D_REENTRANT -I./c_lib/ -o ./app/main.o ./app/main.c
gcc -m32 -Wl,-O1 -o ./app/main -L./c_lib/ -lClib ./app/main.o
./app/main.o: In function `main':
main.c:(.text+0x49): undefined reference to `reverse'
collect2: ld returned 1 exit status
make: *** [app/main] Error 1
Should there be a readable string in the .so file that indicates that reverse is in there?
[mehoggan#hogganz400 shared_library]$ strings ./c_lib/libClib.so.1
__gmon_start__
_init
_fini
__cxa_finalize
_Jv_RegisterClasses
libpthread.so.0
libc.so.6
_edata
__bss_start
_end
GLIBC_2.1.3
gcc -m32 -Wl,-O1 -o ./app/main.o -L./c_lib/ -lClib
You have an error in the variable setting the output file, and the next argument (main.o) is interpreted as the output instead. main.o is thus not loaded and not linked.

Resources