I am trying to build the CB project wxSmith-unix.cbp which has a target type "Dynamic library".
When linking I get a "error" message:
powerpc-apple-darwin8-g++-4.0.1: unrecognized option '-shared'
but it seems the switch is simply ignored.
Looking thru the man page of my g++ I see this:
-shared
Produce a shared object which can then be linked with other objects
to form an executable. Not all systems support this option. For
predictable results, you must also specify the same set of options
that were used to generate code (-fpic, -fPIC, or model suboptions)
when you specify this option.[1]
This option is not supported on Mac OS X.
In addition to this, the linking fails, reporting that _main is undefined.
If I go in to Settings->Compiler..->Other->Advanced.. and remove the "-shared" from the "Dynamic library" command line, I get rid of the error message, but the result is the same.
This tells me that the compiler/linker command for targeting a dynamic library on MacOSX is somehow wrong.
If I change the target to "static library" the link completes without errors, but I cannot really tell what kind of library is produced.
I see that the command line for "Static library" is entirely different, it is using ar and ranlib.
Is this a known issue for CB on MacOSX?
Can anyone clairfy this?
Looking at the Makefile in src/plugins/contrib/wxSmith I guess that libtool should be used instead of g++.
Example snip from my working Makefile for libwxsmith.so:
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
which means, from the definitions i found in the same file:
LIBTOOL = $(SHELL) $(top_builddir)/libtool
CXX = g++
CXXLD = $(CXX)
AM_CXXFLAGS unknown, not found in the file
CXXFLAGS = -O2 -ffast-math -I/opt/local/include -g -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC
AM_LDFLAGS unknown, not found in the file
LDFLAGS = -L/opt/local/lib