User forums > Help
Problem with Dynamic Library CB target on MacOSX
bnilsson:
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
Pecan:
Try changing -shared to -dynamic
And don't forget to remove any -s from compiler/linker from 10.4 compiles.
Stripping has to be done externally to avoid missing symbols.
bnilsson:
Thank's, I'll try it.
--- Quote ---And don't forget to remove any -s from compiler/linker from 10.4 compiles.
--- End quote ---
Please explain in more detail, please.
Pecan:
--- Quote from: bnilsson on October 29, 2006, 01:47:57 pm ---Thank's, I'll try it.
--- Quote ---And don't forget to remove any -s from compiler/linker from 10.4 compiles.
--- End quote ---
Please explain in more detail, please.
--- End quote ---
Google has a lot more details than I.
Also, search this forum for OS X and stipping.
afb:
You might have to verify against the Makefiles for wxSmith,
AFAIK the plugins should be "-bundle" and not "-dynamic" lib ?
FYI: I normally use strip -S afterwards, on Mac OS X...
(that is, when I build with -g debugging symbols enabled)
Navigation
[0] Message Index
[#] Next page
Go to full version