link error with --target gnu --ticpp-shared

82 views
Skip to first unread message

Jerry

unread,
Jul 14, 2011, 5:29:06 PM7/14/11
to TinyXML++
I am building the library on OSX 10.6 (Snow Leopard) using premake
3.7. I am building the "gnu" target. Whenever I included the --ticpp-
shared option, the make command aborts with the following error:
==== Building TiCPP ====
Linking TiCPP
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [../lib/libticppd.so] Error 1
make: *** [TiCPP] Error 2

I have tried --ticpp-shared in combination with the other options, --
unicode and --dynamic-runtime, and it is clear that --ticpp-shared is
causing the problem.

Going further, I think that I can isolate the problem: in the
TiCPP.make file, for bot the Debug and Release configurations, there
are the following definitions:


CPPFLAGS := $(DEPFLAGS) -D "TIXML_USE_TICPP" -D "DEBUG" -D "_DEBUG"
CFLAGS += $(CPPFLAGS) $(TARGET_ARCH) -fPIC -g -Wall -fPIC -O0
CXXFLAGS += $(CFLAGS)
LDFLAGS += -L$(BINDIR) -L$(LIBDIR)
...
TARGET := libticppd.so
BLDCMD = $(CXX) -o $(OUTDIR)/$(TARGET) $(OBJECTS) $(LDFLAGS) $
(RESOURCES) $(TARGET_ARCH)


To be entirely pedantic, BLDCMD should call a linker instead of the
compiler; however, if one insists on using $(CXX) to link, one should
also add the "-shared" flag to the CPPFLAGS. The absence is why it is
looking for the "_main" symbol. I don't know anything about the
premake.lua files used to generate the make-file, otherwise I would
have supplied the patch. Hopefully this gives you enough information.

Jerry

Reply all
Reply to author
Forward
0 new messages