Can't find libraries from Linker using clang-newlib
236 views
Skip to first unread message
Yoichiro Tanaka
unread,
Apr 20, 2015, 8:52:37 PM4/20/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to native-cli...@googlegroups.com
I'm testing a pepper_43 bundle. I know that the NaCl SDK has a new toolchain "clang-newlib" since the pepper_42. My application is using the dependent libraries: libssh2, openssl and glibc-compat. they are included in the naclports. I tried to use these libraries in my application with pepper_43. However, the building failed. It seems that the linker could not find these libraries. In the cases of using other toolchains, the buildings succeeded.
First, I built and installed these libraries to the pepper_43 directory. I think that this was completed successfully.
I guess that the files in the mac_pnacl diretory will be used for the clang-newlib...
Second, I executed the make command to build my application with the clang-newlib. Especially, my Makefile depends on the common.mk file provided by the tools directory of NaCl SDK. The content of my Makefile is the follows:
VALID_TOOLCHAINS := clang-newlib NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..) OUTBASE = .. include $(NACL_SDK_ROOT)/tools/common.mk TARGET = sftp LIBS = ssh2 crypto nacl_io ppapi_cpp ppapi pthread # CFLAGS = -Wall -std=c++0x CFLAGS = -Wall -std=gnu++11 SOURCES = foo.ccbar.cc ... # Build rules generated by macros from common.mk: $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) # The PNaCl workflow uses both an unstripped and finalized/stripped binary. # On NaCl, only produce a stripped binary for Release configs (not Debug). ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG)))) $(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS))) $(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped)) else $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) endif $(eval $(call NMF_RULE,$(TARGET),))
The result of the execution of the make command was "failed". Specifically, Compiling were successfully, but linking was failed with the following output:
[nacl_src] make LINK ../clang-newlib/Release/sftp_unstripped_x86_32.nexe /Applications/nacl/nacl_sdk/pepper_43/toolchain/mac_pnacl/bin/../x86_64-nacl/bin/ld: cannot find -lssh2 /Applications/nacl/nacl_sdk/pepper_43/toolchain/mac_pnacl/bin/../x86_64-nacl/bin/ld: cannot find -lcrypto i686-nacl-clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [../clang-newlib/Release/sftp_unstripped_x86_32.nexe] Error 1
When I changed the toolchain to "newlib" and "pnacl", these were successfully...
I guess that the path for searching library was invalid against using clang-newlib. Should I specify the additional path in my Makefile? Or, is there some bug in the NaCl SDK?
Thank you for your advice.
-Yoichiro
Sam Clegg
unread,
Apr 20, 2015, 10:00:26 PM4/20/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
The naclports build system works around this by adding the
i686-nacl/usr/lib folder to LDFLAGS. You will need to do the same in
your Makefile until we can get this issue resolved in the toolchain.
This issue only effects the i686 compiler so if you make with
TOOLCHAIN=x86_64 it should work fine.