meds
meds

Reputation: 22926

Compiler error when attempting to link static C++ library to MonoDevelop

I created a very simple C++ library in xcode, it was basically:

//Numbers.h
class Numbers
{
public:
 int Get10();
}

//Numbers.cpp
int Numbers::Get10()
{
  return 10;
}

I compiled it to a static (debug) library then carefully followed the instructions here up until step 2, I couldn't progress further because the code won't compile anymore, this is basically what the compiler outputs before giving me the 'mtouch failed with no output' message:

/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -gdwarf-2 -fobjc-legacy-dispatch -fobjc-abi-version=2 -miphoneos-version-min=4.3 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk /var/folders/-M/-Mb3Z8vAGIqK88qeV-fXk++++TI/-Tmp-/tmp216a96e0.tmp/main.x86.o -o /var/folders/-M/-Mb3Z8vAGIqK88qeV-fXk++++TI/-Tmp-/tmp216a96e0.tmp/ChicksnVixens -framework CFNetwork -framework Foundation -framework OpenGLES -framework UIKit -framework AudioToolbox -framework QuartzCore -framework CoreFoundation -framework CoreGraphics -framework AudioToolbox -lz -u _mono_pmip -u _CreateZStream -u _CloseZStream -u _Flush -u _ReadZStream -u _WriteZStream -liconv -lmono-2.0 -lmonotouch -L/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib -u _catch_exception_raise -L/Users/ahmedhakeem/Documents/Projects/goodjabberengine/MyCode/ChicksnVixens -lMylibrary -cxx -force_load /Users/ahmedhakeem/Documents/Projects/goodjabberengine/MyCode/ChicksnVixens/libLogger.a

I very strongly suspect the compiler is not able to find libLogger.a because if I changed libLogger.a to something like abc.a (which doesn't exist) I get the same problem. I do know for sure that libLogger.a exists in the directory specified directory under MyCode/ChicksnVixens/ and it is included in the source hierarchy.

Any ideas on how to fix this? I kind of suspect maybe it has something to do with me using xcode 4 to compile it?

Or the problem could be the arguments I'm passing in:

-gcc_flags "-L${ProjectDir} -lMylibrary -cxx -force_load ${ProjectDir}/libLogger.a"

I had to add 'cxx' as per the instructions but maybe I'm doing something wrong without seeing it?

Upvotes: 0

Views: 245

Answers (1)

Luke
Luke

Reputation: 3655

I believe it is the arguments you're passing in, perhaps try:

-gcc_flags "L${ProjectDir} -lLogger -cxx -force_load ${ProjectDir}/libLogger.a"

(assuming that it is still called libLogger) - it's trying to load libMyLibrary but you're pointing it at libLogger.

Upvotes: 1

Related Questions