public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Linker cannot find library
@ 2011-12-22  1:03 Amittai Aviram
  0 siblings, 0 replies; only message in thread
From: Amittai Aviram @ 2011-12-22  1:03 UTC (permalink / raw)
  To: gcc-help

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@yale.edu
http://www.amittai.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-12-21 23:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-22  1:03 Linker cannot find library Amittai Aviram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).