This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- FlexNet Publisher
- :
- FlexNet Publisher Knowledge Base
- :
- Linux Linking Errors
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Linux Linking Errors
Linux Linking Errors
Summary
Linux Linking ErrorsSynopsis
When linking the application, the following error is seen:
../LINUX/int_lib/liblmgr.a(l_unixmt.o)(.text+0x1cc): In function `l_mt_heartbeat':: undefined reference to `pthread_create'../LINUX/int_lib/liblmgr.a(l_unixmt.o)(.text+0x427): In function `l_mt_free':: undefined reference to `pthread_join'collect2: ld returned 1 exit status.
Discussion
This is caused by missing the "-lpthread" link flag.Adding the "-lpthread" should resolve the problem.
Below is an example using our lmflex sample application:
Makefile :Line1: lmflex: $(SRCDIR)/lmflex.c $(SRCDIR)/lm_code.h $(CLIENTLIB) lmstrip lm_new.oLine2: $(MAKE) lm_new.oLine3: $(CC) $(CFLAGS) $(SRCDIR)/lmflex.cLine4: $(CC) -o lmflex lmflex.o lm_new.o $(CLIENTLIB) $(XTRALIB) $(THREADLIB)Line5: rm lmflex.oLine6: $(STRIP) lmflexLine7: ./lmstrip lmflexLine8: rm -f lm_new.o. After you type "make lmflex" from the shell, you will see the following lines. As you can see Line#3 and Line#4 below refers to the makefile file Line#3 and Line#4 above.Line3: cc -c -g -I../machind -I. -DRELEASE_VERSION -DSUNOS5 -DLM_INTERNAL ../machind/lmflex.cLine4: cc -o lmflex lmflex.o lm_new.o liblmgr.a libcrvs.a libsb.a -lsocket -lnsl -lintl -lsocket -lnsl -lintl -lpthread -lpthread.
No ratings