OSX / Darwin unresolved characters when binding functions from <math.h>
I am moving a large (~ 1M LOC) project from Window / Visual Studio to other platforms, the first of which is Mac OS X.
Initially, the project was configured as Visual Studio solutions and projects, but now I use (excellent) Premake ( http://industriousone.com/premake ) to create project files for several platforms (VS, Xcode, GMake).
I configured, ported and created the first few projects without any significant problems, but ported the math library, I ran into this strange linking error that I could not solve: Any functions used from math .h will not link (causing unresolved characters )
For reference, I use Premake v4.2.1 to create projects for Xcode v3.2.1, which builds using gcc v4.2 for the x86_64 architecture. (All this on 64-bit Snow Leopard) I tried to convince gcc to link and build everything against the “famous” SDK by adding -isysroot / Developer / SDKs / MacOSX10.6.sdk -mmacosx-version-min = 10.6 to the build command line.
Now, under normal circumstances, adding -lm should take care of this, however, in Darwin, these math libraries are included in libSystem, which, as far as I can tell, is implicitly related to gcc / ld.
I tried to create a dummy project from Xcode, which is just starting:
float f = log2(2.0)+log2f(3.f)+log1p(1.1)+log1pf(1.2f)+sin(8.0);
std::cout << f << std::endl;
and, as expected, this is just fine. However, if I add the same to the code inside the Premake project, all of these math functions will ultimately remain unresolved.
, 'native' XCode XCode, ( , ).
"" :
/Developer/usr/bin/g++-4.2 -arch x86_64 -dynamiclib -isysroot /Developer/SDKs/MacOSX10.6.sdk -Lsomepath -Fsomepath -filelist somefile -install_name somename -mmacosx-version-min=10.6 -single_module -compatibility_version 1 -current_version 1 -o somename
:
/Developer/usr/bin/g++-4.2 -arch x86_64 -dynamiclib -Lsomepath -Fsomepath -filelist somefile -install_name somename -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 somelib.a somelib2.a somelib.dylib somelib2.dylib -single_module -compatibility_version 1 -current_version 1 -o somename
, , . - gcc- , ?