Skip to contentSkip to conversation

fix lib-not-found error when compile for the second time

PATCH In review Caspar Zhang 3 participants 3 messages Dec 18, 2009 – Dec 19, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 272150129.565151261136307450.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com

#1 lore raw

PATCH 1/1 fix lib-not-found error when compile for the second time

Hi all, I meet a problem, if I compile and install ltp for the first time, ltp can pass the compilation, but if I don't delete installation direcotry (originally been /opt/ltp) and try to build ltp for the second time in another ltp source folder, ltp failes in compiling:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -I/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/include -I/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl/../libcontrollers -I../../../../include -I../../../../include -L/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl/../libcontrollers
-L../../../../lib cpuctl_def_task01.c -lltp -lm -lcontrollers -o
cpuctl_def_task01
cpuctl_def_task01.c: In function ‘main’:
cpuctl_def_task01.c:90: warning: ‘num_cpus’ may be used uninitialized in
this function
cpuctl_def_task01.c:90: warning: ‘test_num’ may be used uninitialized in
this function
cpuctl_def_task01.c:94: warning: ‘my_group_num’ may be used
uninitialized in this function
/usr/bin/ld: cannot find -lcontrollers
collect2: ld returned 1 exit status
make[5]: *** [cpuctl_def_task01] Error 1
make[5]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl' make[4]: *** [all] Error 2
make[4]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers' make[3]: *** [all] Error 2
make[3]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases'
make[1]: *** [testcases-all] Error 2
make[1]: Leaving directory
`/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130'
make: *** [build] Error 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After investigating, I find the key to solve the problem:

Suppose we build ltp to /opt/ltp.

In testcases/kernel/controllers/Makefile[1] and testcases/network/sctp/Makefile[2], library files which need to be built are defined in /opt/ltp/lib:

LIB := $(DESTDIR)/$(libdir)/libcontrollers.a

when compiling&linking objects in controllers/ subdirs, the LDFLAGS paths are:

-L$(topbuilddir)/testcases/kernel/controllers/libcontrollers -L../../../../lib (see the error messages above)

/opt/ltp/lib isn't included in LDFLAGS paths here.

The first time when you compile ltp, a libcontrollers.a will be generated under $(topbuilddir)/testcases/kernel/controllers/libcontrollers, so we can find libcontrollers.a in LDFLAGS paths and the compilation could still pass. But if you don't delete /opt/ltp and try to build ltp in another source directory, error will occur. Since $(LIB) in Makefile[1] and Makefile[2] are already up-to-date, no libcontrollers.a will be generated in $(topbuilddir)/testcases/kernel/controllers/libcontrollers due to makefile policy. Thus, ltp can't find libcontrollers.a in LDFLAGS paths.

So we can fix this problem in two ways: add $(DESTDIR)/$(libdir)/lib to LDFLAGS or change $(LIB) paths in Makefile[1] and Makefile[2]. Find details in my attachments.

Thanks,
Caspar

include/mk/env_post.mk +1 -1
diff -Naur a/include/mk/env_post.mk b/include/mk/env_post.mk
@@ -35,7 +35,7 @@
 # For config.h, et all.
 CPPFLAGS			+= -I$(top_srcdir)/include -I$(top_builddir)/include
 
-LDFLAGS				+= -L$(top_builddir)/lib
+LDFLAGS				+= -L$(top_builddir)/lib -L$(DESTDIR)/$(libdir)
 
 MAKE_TARGETS			?= $(notdir $(patsubst %.c,%,$(wildcard $(abs_srcdir)/*.c)))
 
testcases/kernel/controllers/Makefile +1 -1
diff -Naur a/testcases/kernel/controllers/Makefile b/testcases/kernel/controllers/Makefile
@@ -25,8 +25,8 @@
 include $(top_srcdir)/include/mk/env_pre.mk
 
 INSTALL_TARGETS		:= *.sh
-LIB			:= $(DESTDIR)/$(libdir)/libcontrollers.a
 LIBDIR			:= libcontrollers
+LIB 			:= $(LIBDIR)/libcontrollers.a
 FILTER_OUT_DIRS		:= $(LIBDIR)
 
 $(LIBDIR):
testcases/network/sctp/Makefile +2 -2
diff -Naur a/testcases/network/sctp/Makefile b/testcases/network/sctp/Makefile
@@ -24,10 +24,10 @@
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-LIBSCTP			:= $(DESTDIR)/$(libdir)/libsctp.a
-LIBSCTPUTIL		:= $(DESTDIR)/$(libdir)/libsctputil.a
 LIBSCTPDIR		:= lib
 LIBSCTPUTILDIR		:= testlib
+LIBSCTP			:= $(LIBSCTPDIR)/libsctp.a
+LIBSCTPUTIL		:= $(LIBSCTPUTILDIR)/libsctputil.a
 
 FILTER_OUT_DIRS		:= $(LIBSCTPDIR) $(LIBSCTPUTILDIR)
 

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 65 lines · Caspar Zhang

Hi all, I meet a problem, if I compile and install ltp for the first time, ltp can pass the compilation, but if I don't delete installation direcotry (originally been /opt/ltp) and try to build ltp for the second time in another ltp source folder, ltp failes in compiling:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall

(quoted diff) +0 -5
-I/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/include
-I/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl/../libcontrollers
-I../../../../include -I../../../../include
-L/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl/../libcontrollers
-L../../../../lib  cpuctl_def_task01.c   -lltp -lm -lcontrollers -o

cpuctl_def_task01
cpuctl_def_task01.c: In function ‘main’:
cpuctl_def_task01.c:90: warning: ‘num_cpus’ may be used uninitialized in
this function
cpuctl_def_task01.c:90: warning: ‘test_num’ may be used uninitialized in
this function
cpuctl_def_task01.c:94: warning: ‘my_group_num’ may be used
uninitialized in this function
/usr/bin/ld: cannot find -lcontrollers
collect2: ld returned 1 exit status
make[5]: *** [cpuctl_def_task01] Error 1
make[5]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl' make[4]: *** [all] Error 2
make[4]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers' make[3]: *** [all] Error 2
make[3]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel' make[2]: *** [all] Error 2
make[2]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases'
make[1]: *** [testcases-all] Error 2
make[1]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130'
make: *** [build] Error 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After investigating, I find the key to solve the problem:

Suppose we build ltp to /opt/ltp.

In testcases/kernel/controllers/Makefile[1] and testcases/network/sctp/Makefile[2], library files which need to be built are defined in /opt/ltp/lib:

LIB := $(DESTDIR)/$(libdir)/libcontrollers.a

when compiling&linking objects in controllers/ subdirs, the LDFLAGS paths are:

(quoted diff) +0 -2
-L$(topbuilddir)/testcases/kernel/controllers/libcontrollers
-L../../../../lib (see the error messages above)

/opt/ltp/lib isn't included in LDFLAGS paths here.

The first time when you compile ltp, a libcontrollers.a will be generated under $(topbuilddir)/testcases/kernel/controllers/libcontrollers, so we can find libcontrollers.a in LDFLAGS paths and the compilation could still pass. But if you don't delete /opt/ltp and try to build ltp in another source directory, error will occur. Since $(LIB) in Makefile[1] and Makefile[2] are already up-to-date, no libcontrollers.a will be generated in $(topbuilddir)/testcases/kernel/controllers/libcontrollers due to makefile policy. Thus, ltp can't find libcontrollers.a in LDFLAGS paths.

Quoted 3 lines

So we can fix this problem in two ways: add $(DESTDIR)/$(libdir)/lib to LDFLAGS or change $(LIB) paths in Makefile[1] and Makefile[2]. Find details in my attachments.

Thanks. I too faced the same thing sometime back. Garret, please apply the solution you would like the most.

Caspar,

There was also a problem with the sctp library. Did you check that out ?

Regards--
Subrata

Quoted 10 lines

Thanks,
Caspar
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 73 lines · Subrata Modak
Quoted 65 lines · Caspar Zhang

Hi all, I meet a problem, if I compile and install ltp for the first time, ltp can pass the compilation, but if I don't delete installation direcotry (originally been /opt/ltp) and try to build ltp for the second time in another ltp source folder, ltp failes in compiling:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall

(quoted diff) +0 -5
-I/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/include
-I/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl/../libcontrollers
-I../../../../include -I../../../../include
-L/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl/../libcontrollers
-L../../../../lib  cpuctl_def_task01.c   -lltp -lm -lcontrollers -o

cpuctl_def_task01
cpuctl_def_task01.c: In function ‘main’:
cpuctl_def_task01.c:90: warning: ‘num_cpus’ may be used uninitialized in
this function
cpuctl_def_task01.c:90: warning: ‘test_num’ may be used uninitialized in
this function
cpuctl_def_task01.c:94: warning: ‘my_group_num’ may be used
uninitialized in this function
/usr/bin/ld: cannot find -lcontrollers
collect2: ld returned 1 exit status
make[5]: *** [cpuctl_def_task01] Error 1
make[5]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers/cpuctl' make[4]: *** [all] Error 2
make[4]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel/controllers' make[3]: *** [all] Error 2
make[3]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases/kernel' make[2]: *** [all] Error 2
make[2]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130/testcases'
make[1]: *** [testcases-all] Error 2
make[1]: Leaving directory `/mnt/tests/kernel/distribution/ltp/20091130/ltp-full-20091130'
make: *** [build] Error 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After investigating, I find the key to solve the problem:

Suppose we build ltp to /opt/ltp.

In testcases/kernel/controllers/Makefile[1] and testcases/network/sctp/Makefile[2], library files which need to be built are defined in /opt/ltp/lib:

LIB                   := $(DESTDIR)/$(libdir)/libcontrollers.a

when compiling&linking objects in controllers/ subdirs, the LDFLAGS paths are:

(quoted diff) +0 -2
-L$(topbuilddir)/testcases/kernel/controllers/libcontrollers
-L../../../../lib (see the error messages above)

/opt/ltp/lib isn't included in LDFLAGS paths here.

The first time when you compile ltp, a libcontrollers.a will be generated under $(topbuilddir)/testcases/kernel/controllers/libcontrollers, so we can find libcontrollers.a in LDFLAGS paths and the compilation could still pass. But if you don't delete /opt/ltp and try to build ltp in another source directory, error will occur. Since $(LIB) in Makefile[1] and Makefile[2] are already up-to-date, no libcontrollers.a will be generated in $(topbuilddir)/testcases/kernel/controllers/libcontrollers due to makefile policy. Thus, ltp can't find libcontrollers.a in LDFLAGS paths.

Quoted 3 lines

So we can fix this problem in two ways: add $(DESTDIR)/$(libdir)/lib to LDFLAGS or change $(LIB) paths in Makefile[1] and Makefile[2]. Find details in my attachments.

Thanks. I too faced the same thing sometime back. Garret, please apply the solution you would like the most.

Quoted 3 lines

Caspar,

There was also a problem with the sctp library. Did you check that out ?

Caspar,
Thanks again for your good eye in spotting these two leftover
issues I didn't resolve earlier. They have just been fixed on HEAD. Cheers,
-Garrett

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list