Linker cannot find library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am building an OpenMP application using my own build of GCC, in which I have altered the OpenMP support library, libgomp.  (This project is called "DOMP.")  In this library, I define alternatives to the "malloc" functions, whose names are all prefixed with "domp_" to distinguish them from normal malloc.  The source file #includes a file that uses #define to have the preprocessor replace every instance of "malloc" with "domp_malloc," etc., before compilation.  If I use a Makefile whose rule includes compiling and linking in one step, I have no problem building my application.  However, if I use a Makefile that specifies separate compilation and linking steps, even though I supply a directory search path for my DOMP library with the -L option, the linker cannot find the definition of "domp_malloc."  Why not, and what can I do about this?

Suppose my home directory is called "/home/amittai" and my special GCC is in /home/amitai/gcc_install, which holds the GCC executable in its /bin subdirectory and the altered libgomp library (including the definition of domp_malloc) in its /lib64 directory.  (I am building and running on an x86_64 machine under Ubuntu Gnu/Linux for x86_64.)  The application is the NPB OpenMP benchmark called "IS."  Here is the Makefile rule that works correctly:

/home/amittai/gcc_install/bin/gcc -fopenmp -fno-common -static -DDOMP -g -o is.S head.s ../common/c_print_results.c ../common/c_timers.c ../common/c_wtime.o is.c tail.s -lm -L/home/amittai/gcc_install/lib64


And here are the Makefile rules that result in a linker error, along with the error:

cd ../common; /home/amittai/gcc_install/bin/gcc   -c  -O -fopenmp -fno-common -static -DDOMP -g c_print_results.c
cd ../common; /home/amittai/gcc_install/bin/gcc   -c  -O -fopenmp -fno-common -static -DDOMP -g c_timers.c
cd ../common; /home/amittai/gcc_install/bin/gcc   -c  -O -fopenmp -fno-common -static -DDOMP -g -o c_wtime.o ../common/wtime.c
/home/amittai/gcc_install/bin/gcc  -O -fopenmp -DDOMP -o ../bin/is.S head.s is.o ../common/c_print_results.o ../common/c_timers.o ../common/c_wtime.o tail.s -lm -L/home/amittai/gcc_install/lib64
is.o: In function `alloc_key_buff':
/home/amittai/npb/NPB3.2-OMP/IS/is.c:458: undefined reference to `domp_malloc'
/home/amittai/npb/NPB3.2-OMP/IS/is.c:464: undefined reference to `domp_malloc'
collect2: ld returned 1 exit status
make: *** [../bin/is.S] Error 1

Thanks!



Amittai Aviram
PhD Student in Computer Science
Yale University
646 483 2639
amittai.aviram@xxxxxxxx
http://www.amittai.com




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux