Link issues with QtMacExtras using Qt 5.0.2 - macos

I need the QtMacExtras framework to use its QMacCocoaViewContainer class.
I have been able to get the framework and compile it easily using qmake/make without issues.
However, when trying to link my binary with it I get undefined symbols errors.
The compilation of the objects works like a charm.
g++ -mmacosx-version-min=10.7 --exported_symbols_list=symbols.exp -Wl,-x -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib -o myBinary *.o -bind_at_load -F/pathToMy/Frameworks -framework QtCore -framework QtMacExtras -framework QtGui -framework QtWidgets #...
Undefined symbols for architecture x86_64:
"QMacCocoaViewContainer::QMacCocoaViewContainer(objc_object*, QWidget*)", referenced from:
WbDockWidget::setContentWindowId(unsigned long long)in WbDockWidget.o
ld: symbol(s) not found for architecture x86_64
The code to instantiate the class is the following:
#include <QtMacExtras/QMacCocoaViewContainer>
// ...
NSView *view = reinterpret_cast<NSView *>(id);
QWidget *widget = new QMacCocoaViewContainer(view, this);
Commenting this code allows to compile my project.
The framework seems correctly linked, seems to include correctly the headers, and seems to contain the symbols (!):
$ nm -g Frameworks/QtMacExtras.framework/Versions/5/QtMacExtras | grep -i cocoa
0000000000009240 T __ZN22QMacCocoaViewContainer11qt_metacallEN11QMetaObject4CallEiPPv
0000000000009200 T __ZN22QMacCocoaViewContainer11qt_metacastEPKc
0000000000004c00 T __ZN22QMacCocoaViewContainer12setCocoaViewEP6NSView
0000000000011130 S __ZN22QMacCocoaViewContainer16staticMetaObjectE
0000000000004b60 T __ZN22QMacCocoaViewContainerC1EP6NSViewP7QWidget
0000000000004b70 T __ZN22QMacCocoaViewContainerC2EP6NSViewP7QWidget
0000000000004d10 T __ZN22QMacCocoaViewContainerD0Ev
0000000000004d40 T __ZN22QMacCocoaViewContainerD1Ev
0000000000004d90 T __ZN22QMacCocoaViewContainerD2Ev
00000000000091e0 T __ZNK22QMacCocoaViewContainer10metaObjectEv
0000000000004e20 T __ZNK22QMacCocoaViewContainer9cocoaViewEv
0000000000011360 S __ZTI22QMacCocoaViewContainer
000000000000ce70 S __ZTS22QMacCocoaViewContainer
0000000000011160 S __ZTV22QMacCocoaViewContainer
0000000000004d50 T __ZThn16_N22QMacCocoaViewContainerD0Ev
0000000000004e10 T __ZThn16_N22QMacCocoaViewContainerD1Ev
Any suggestion to be able to use this class would be more than welcome.
Sincerely.

This problem occurs when you build as C++.
The easiest way to fix this is to switch the extension to .mm, but if you force the toolchain to build as Objective C++ by whatever means it should fix the issue.

Related

Xcode 6.2 OSX Undefined symbols for functions in other files

I'm sure this is a total nube question but if someone could explain to me what's going wrong I'd be very grateful.
I create a new Cocoa App in XCode. Call it LinkerTest. This basic app will build and run, putting a simple blank window up.
Add a new .cpp file using the C++ File template. Call it Test.cpp. This creates Test.h too.
In Test.cpp add a simple function:
int TestMe(void)
{
return 1;
}
Declare my function in Test.h
int TestMe(void);
In my AppDelegate.m (which was created automatically when I create the app) add
#include "Test.h"
In the applicationDidFinishLaunching method add:
printf("Test = %d\n", TestMe());
Now try to build. Everything compiles ok, but it fails to link. This is the linker command:
Ld Build/Products/Debug/LinkerTest.app/Contents/MacOS/LinkerTest normal x86_64
cd /Users/chip/LinkerTest
export MACOSX_DEPLOYMENT_TARGET=10.10
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/chip/LinkerTest/Build/Products/Debug -F/Users/chip/LinkerTest/Build/Products/Debug -filelist /Users/chip/LinkerTest/Build/Intermediates/LinkerTest.build/Debug/LinkerTest.build/Objects-normal/x86_64/LinkerTest.LinkFileList -Xlinker -rpath -Xlinker #executable_path/../Frameworks -mmacosx-version-min=10.10 -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -Xlinker -dependency_info -Xlinker /Users/chip/LinkerTest/Build/Intermediates/LinkerTest.build/Debug/LinkerTest.build/Objects-normal/x86_64/LinkerTest_dependency_info.dat -o /Users/chip/LinkerTest/Build/Products/Debug/LinkerTest.app/Contents/MacOS/LinkerTest
And this is the error I get:
Undefined symbols for architecture x86_64:
"_TestMe", referenced from:
-[AppDelegate applicationDidFinishLaunching:] in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So any idea what I've done wrong? Seems to me that adding the file it should link too, but it doesn't. I know the file Test.cpp gets compiled, if I add garbage to the file, then the compiler immediately yacks on that garbage.
EDIT: A couple more things.
1) Looking at this stackoverflow(Getting XCode to include, compile and link existing (C++) codebase in XCode 4.3(.1)) question it seems similar but not my issue. I can confirm that my test.cpp is listed in my Compile Sources under Build Phases.
2) Looking in the LinkerTest/Build/Intermediates/LinkerTest.build/Debug/LinkerTest.build/Objects-normal/x86_64 folder I find Test.o, Test.d, and Test.dia which suggests to me that Test.cpp is in fact compiling. In that folder I also find LinkerTest.LinkFileList which when opened with a text editor shows that Test.o should be linked.
The answer is that when you create a default Cocoa app the AppDelegate file is a .m file. Changing that file to be AppDelegate.mm fixes the problem. My uninformed guess is that a .m file will only handle .c files and to correctly handle .cpp files you must use .mm files. Why xcode's default files for a default Cocoa App wouldn't be .mm files is beyond my pay grade, but there it is.

ld: library not found after switching to VTK6

I changed to VTK-6 and now I can not compile anymore due to library not found..With vtk-5 it works perfectly fine.
c++ -o loch -Wall lxTR.o lxOGLFT.o lxSetup.o lxRender.o lxWX.o lxImgIO.o lxLRUD.o lxFile.o lxSTree.o lxData.o lxMath.o lxSView.o lxSScene.o lxGUI.o lxGLC.o lxOptDlg.o lxAboutDlg.o img.o -lz -L/usr/X11R6/lib -lwx_osx_cocoau_gl-2.9 -L/usr/local/Cellar/wxmac/2.9.5.0/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -framework QuickTime -lwx_osx_cocoau-2.9 -L/usr/local/lib -lvtkHybrid -lvtkImaging -lvtkIO -lvtkGraphics -lvtkFiltering -lvtkCommon -lvtkjpeg -lvtkpng -lvtkzlib -lvtksys -lfreetype
ld: library not found for -lvtkHybrid
Any idea what they changed?
It seems like the component libraries have changed in VTK 6: see their wiki page for some details. For example, after configuring to link everything in VTK with cmake, the VTK_LIBRARIES variable is set with the following list of libraries to be linked:
vtkalglib;vtkChartsCore;vtkCommonColor;vtkCommonDataModel;vtkCommonMath;vtkCommonCore;vtksys;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkInfovisCore;vtkFiltersExtraction;vtkCommonExecutionModel;vtkFiltersCore;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkIOImage;vtkDICOMParser;vtkIOCore;vtkzlib;vtkmetaio;vtkjpeg;vtkpng;vtktiff;vtkIOXMLParser;vtkexpat;vtkRenderingFreeType;vtkfreetype;vtkftgl;vtkRenderingOpenGL;vtkImagingHybrid;vtkDomainsChemistry;vtkIOXML;vtkIOGeometry;vtkjsoncpp;vtkexoIIc;vtkNetCDF;vtkNetCDF_cxx;vtkhdf5_hl;vtkhdf5;vtkFiltersAMR;vtkParallelCore;vtkIOLegacy;vtkFiltersFlowPaths;vtkFiltersGeneric;vtkFiltersHybrid;vtkImagingSources;vtkFiltersHyperTree;vtkFiltersImaging;vtkImagingGeneral;vtkFiltersModeling;vtkFiltersParallel;vtkFiltersParallelImaging;vtkFiltersProgrammable;vtkFiltersSelection;vtkFiltersTexture;vtkFiltersVerdict;verdict;vtkGeovisCore;vtkInfovisLayout;vtkInteractionStyle;vtkInteractionWidgets;vtkRenderingAnnotation;vtkImagingColor;vtkRenderingVolume;vtkViewsCore;vtkproj4;vtkgl2ps;vtkGUISupportQt;vtkGUISupportQtOpenGL;vtkImagingMath;vtkImagingMorphological;vtkImagingStatistics;vtkImagingStencil;vtkInteractionImage;vtkIOAMR;vtkIOEnSight;vtkIOExodus;vtkIOExport;vtkRenderingGL2PS;vtkIOImport;vtkIOInfovis;vtklibxml2;vtkIOLSDyna;vtkIOMINC;vtkIOMovie;vtkoggtheora;vtkIONetCDF;vtkIOParallel;vtkIOPLY;vtkIOSQL;vtksqlite;vtkIOVideo;vtkRenderingFreeTypeOpenGL;vtkRenderingHybridOpenGL;vtkRenderingImage;vtkRenderingLabel;vtkRenderingLOD;vtkRenderingVolumeAMR;vtkRenderingVolumeOpenGL;vtkViewsContext2D;vtkViewsGeovis;vtkViewsInfovis
And note that vtkCommon and vtkHybrid are no longer on the named list because it's been re-organized, so you'll need to adjust what libraries you link.
Try This.
static
{
vtkNativeLibrary.LoadAllNativeLibraries();//Try to load all library
}
The vtkNativeLibrary class used to load native library more easily.
rather than usual
static {
//System.loadLibrary("vtkCommonJava");
//System.loadLibrary("vtkFilteringJava");
//System.loadLibrary("vtkIOJava");
//System.loadLibrary("vtkImagingJava");
//System.loadLibrary("vtkGraphicsJava");
//System.loadLibrary("vtkRenderingJava");
}
that works only with older version of VTK and not VTK6 versions

Setting up OpenCV in QT on OSX

I am trying to set up OpenCV to work with QT on OSX 10.7.5/MacbookPro 2.5 Ghz Intel Core 2 Duo. I've seen a few related question here (How to link opencv in QtCreator and use Qt library and How do you set up OpenCV with QT in OSX?) but there isn't much detail. On the QT site and in my web searches all of the information seems to be about Windows or Linux.
I've listed what my setup and code is below. When I run the code I am getting an error: :-1: error: symbol(s) not found for architecture x86_64
Does this mean it's not finding stuff because the paths are wrong or because I may have built openCV for x86_32? Is there a way of checking the latter? I'm not so savvy with parts of the configuration and setup process.
Update 2
The console output is below - perhaps the error is obvious?
02:44:38: Running steps for project RP_openCV_01...
02:44:38: Configuration unchanged, skipping qmake step.
02:44:38: Starting: "/usr/bin/make"
clang++ -headerpad_max_install_names -mmacosx-version-min=10.6 -o RP_openCV_01 main.o -L/usr/local/lib -1ibopencv_core.2.4.6,dylib -1ibopencv_imgproc.2.4.6.dylib -F/Users/rise/Qt5.0.2/5.0.2/clang_64/lib -framework QtCore
clang: warning: argument unused during compilation: '-1ibopencv_core.2.4.6,dylib'
clang: warning: argument unused during compilation: '-1ibopencv_imgproc.2.4.6.dylib'
Undefined symbols for architecture x86_64:
"cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
_main in main.o
"cv::namedWindow(std::string const&, int)", referenced from:
_main in main.o
"cv::Mat::deallocate()", referenced from:
_main in main.o
"cv::imread(std::string const&, int)", referenced from:
_main in main.o
"cv::imshow(std::string const&, cv::_InputArray const&)", referenced from:
_main in main.o
"cv::waitKey(int)", referenced from:
_main in main.o
"cv::fastFree(void*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [RP_openCV_01] Error 1
02:44:38: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project RP_openCV_01 (kit: Desktop Qt 5.0.2 clang 64bit)
When executing step 'Make'
What I have so far (the tl;dr):
built and installed the latest version of openCV (2.4.6) from source and tested it with some command line programs.
installed the latest version of QT (5.1) and am able to run all the examples, etc.
specified the paths in the project file (below)
QT += core
QT -= gui
TARGET = RP_openCV_01
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/local/include\
LIBS += -L/usr/local/lib
tried to specify the path in the project settings (below). I added /usr/local/include and /usr/local/lib
The simple example code in main.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main() {
// read an image
cv::Mat image= cv::imread("dog.jpg");
// create image window named "My Image"
cv::namedWindow("My Image");
// show the image on window
cv::imshow("My Image", image);
// wait key for 5000 ms
cv::waitKey(5000);
return 1;
}
Update 1
Another thing I tried based on a tutorial was to specify the libs in the QT profile (as in image below). The tutorial was for Windows though and I didn't know if or how OSX is different. Where in the Windows example it is -1ibopencv_core246d I tried it with and without the separating periods but without the "d". Of course the full name of a lib is "libopencv_core.2.4.6.dylib" etc.
These sorts of important details always trip me up but it's often assumed in tutorials that one knows this stuff.
LIBS += -L/usr/local/lib \
-1ibopencv_core.2.4.6 \
-1ibopencv_imgproc.2.4.6 \
-1ibopencv_features2d.2.4.6 \
-1ibopencv_highgui.2.4.6
Just a naive mistake
The proper declaration is:
LIBS += -L/usr/local/lib \
-lopencv_core \
-lopencv_imgproc \
-lopencv_features2d\
-lopencv_highgui
I just stumbled over the same problem. Here is how I solved it:
As sansuiso already suggested, the problem appears to be the C++-STD-lib you are trying to link against. You are probably trying to link libc++ (LLVM ...) but instead libstdc++ (GNU C++ ...) should be used.
Using the Qt Creator you can add the following to your .pro-file:
mac: CONFIG += MAC_CONFIG
MAC_CONFIG {
QMAKE_CXXFLAGS = -std=c++11 -stdlib=libstdc++ -mmacosx-version-min=10.7
QMAKE_LFLAGS = -std=c++11 -stdlib=libstdc++ -mmacosx-version-min=10.7
}
This answer could also be interesting for your problem: https://stackoverflow.com/a/12852913/1141118
Hope this helps!
You are facing 2 potential issues here:
first one is, on Mac platforms, depending on the compiler (clang or gcc) you will not link against the same stdc++ library (I ran into this issue while trying to get some static opencv lib working with an iOS project). However, it does not seem to be the case here since you do not have C++ errors, but it's worth checking what compiler you use in each case;
second one, QtCreator is a graphical app. Thus it is not aware of your terminal-session settings. This includes the path to dynamic libraries in /usr/local. You can avoid this by different approaches: using a static opencv lib, using install_tool to change the path to the library coded in the output binary, or by using the preferences of QtCreator to set the DYLD_LIBRARY_PATH variable to something like /usr/local/lib when it runs your program.
Here are the steps I took to setup Opencv in QT in OSX:
1- Install QT
2- Install OpenCV4
3- Add the following lines in the project file:
INCLUDEPATH += /usr/local/include/opencv4\
LIBS += -L/usr/local/lib \
-lopencv_core \
-lopencv_imgproc \
-lopencv_features2d\
-lopencv_highgui
QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
4- In the Project section, under the Built section, uncheck the following:
Add build library search path to DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH
The following links are helpful:
Dlink
Warning Version

Unit testing Objective-C++ frameworks with Xcode 4.x

I'm writing a framework using Objective C++ and I am having trouble setting up unit tests for it.
Compiling just the framework target works fine.
But when I tell Xcode to compile and run the test bundle I get:
Ld ~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Products/Debug/TestFrameworkTests.octest/Contents/MacOS/TestFrameworkTests normal x86_64
cd "~/Projects/TestFramework"
setenv MACOSX_DEPLOYMENT_TARGET 10.7
"/Applications/Xcode 4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" -arch x86_64 -bundle -isysroot "/Applications/Xcode 4.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk" -L~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib -F~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Products/Debug "-F/Applications/Xcode 4.5.app/Contents/Developer/Library/Frameworks" -filelist ~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Intermediates/TestFramework.build/Debug/TestFrameworkTests.build/Objects-normal/x86_64/TestFrameworkTests.LinkFileList -mmacosx-version-min=10.7 -v -fobjc-arc -fobjc-link-runtime -fprofile-arcs -stdlib=libc++ -framework SenTestingKit -framework Cocoa -framework TestFramework -o ~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Products/Debug/TestFrameworkTests.octest/Contents/MacOS/TestFrameworkTests
Apple clang version 4.0 (tags/Apple/clang-421.10.48) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
"/Applications/Xcode 4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -bundle -macosx_version_min 10.7.0 -syslibroot "/Applications/Xcode 4.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk" -o ~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Products/Debug/TestFrameworkTests.octest/Contents/MacOS/TestFrameworkTests -L~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib -filelist ~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Intermediates/TestFramework.build/Debug/TestFrameworkTests.build/Objects-normal/x86_64/TestFrameworkTests.LinkFileList -framework SenTestingKit -framework Cocoa -framework TestFramework -force_load "/Applications/Xcode 4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a" -framework Foundation -lobjc -lc++ "/Applications/Xcode 4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/4.0/lib/darwin/libclang_rt.profile_osx.a" -lSystem "/Applications/Xcode 4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/4.0/lib/darwin/libclang_rt.osx.a" -F~/Library/Developer/Xcode/DerivedData/TestFramework-axdefcbatoubjbbfqiyxildilobl/Build/Products/Debug "-F/Applications/Xcode 4.5.app/Contents/Developer/Library/Frameworks"
Undefined symbols for architecture x86_64:
"Foo::Bar::Bar()", referenced from:
-[FooBar_Tests testBaz] in FooBar_Tests.o
"Foo::Bar::baz() const", referenced from:
-[FooBar_Tests testBaz] in FooBar_Tests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have:
C++ Language Dialect: c++11
C++ Standard Library: libc++
set on both build targets (framework & test bundle).
And I am of course linking against the framework in my test bundle target.
Furthermore, all framework headers are marked public.
I also tried adding the framework files to the test bundle's target and leaving them out. None of these fixed the problem.
I am a bit puzzled as to what's going wrong here, right now. Any ideas?
This is how my C++ class looks like (kind of):
//FooBar.hh
namespace Foo {
class Bar {
public:
bool baz() const;
}
}
//FooBar.mm
#import "FooBar.hh"
namespace Foo {
bool Bar::baz() const {
return true;
}
}
And this my test case:
//FooBar_Tests.hh
#import <SenTestingKit/SenTestingKit.h>
#interface FooBar_Tests : SenTestCase
#end
//FooBar_Tests.mm
#import "FooBar_Tests.hh"
#import <TestFramework/FooBar.hh>
//this one fails as well (compiles fine, fails one linkage):
//#import "FooBar.hh"
#implementation FooBar_Tests
- (void)testBaz {
Foo::Bar bar();
STAssertEquals(bar.baz(), true, nil);
}
Edit: Split code up into .hh&.mm files. Still getting the same errors though.
One possible problem is that your unit tests are in the header file. Header files do not do much in OCUnit. You can even get rid of the header file and put all your test case code in the implementation file. Add an Objective-C unit test class to your project, give it the extension .mm, and move your test case code there. Does that fix the problem?
When I unit test C++ code with OCUnit, I find I have to add the C++ files in my app to the unit test target to avoid link errors. I'm not sure if it applies to Objective-C++ code, but it's something to look into.
I eventually added a new unit test target to my project, enabled C++11 and tried compiling/running it. Success.
Somehow my original unit test target must have gone bad in regards to C++11. Had compiled just fine before.
Now it's time to migrate my test cases to the new test bundle, I guess.
…and I thought I was going mad. Oh well…

How can I compile and use Haskell as a C library using Xcode LLVM compiler?

I want to set up a project to take my .hs code, and my main .c program, and result in a statically linked executable through the use of LLVM compiler. I can get things working via ghc command line options to build a .hs, produce the stubs, and compile and link a driver application using ghc entirely. However, I get various issues within Xcode.
My first issue was that I of course need to use 32 bit compiling environment in Xcode. That solved, I had to fiddle with paths to explicitly include the HsFFI.h. That solved, I get a linker error:
Ld "build/Debug/FFI Test.app/Contents/MacOS/FFI Test" normal i386
cd "/Users/rcl/TestXCodeProjects/FFI Test"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/clang -arch i386
-isysroot /Developer/SDKs/MacOSX10.6.sdk
"-L/Users/rcl/TestXCodeProjects/FFI Test/build/Debug"
"-L/Users/rcl/TestXCodeProjects/FFI Test/FFI Test"
"-F/Users/rcl/TestXCodeProjects/FFI Test/build/Debug"
-filelist "/Users/rcl/TestXCodeProjects/FFI Test/build/FFI Test.build/
Debug/FFI Test.build/Objects-normal/i386/FFI Test.LinkFileList"
-mmacosx-version-min=10.6 -framework Cocoa
"/Users/rcl/TestXCodeProjects/FFI Test/FFI Test/ForeignExportCost.a"
-o "/Users/rcl/TestXCodeProjects/FFI Test/build/Debug/FFI Test.app/
Contents/MacOS/FFI Test"
Undefined symbols for architecture i386:
"_hs_init", referenced from:
-[FFI_TestAppDelegate applicationDidFinishLaunching:] in FFI_TestAppDelegate.o
"_simpleFunction", referenced from:
-[FFI_TestAppDelegate applicationDidFinishLaunching:] in FFI_TestAppDelegate.o
"_hs_exit", referenced from:
-[FFI_TestAppDelegate applicationDidFinishLaunching:] in FFI_TestAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The "simpleFunction" is in "ForeignExportCost.a" library which I compile using ghc like this:
ghc -no-hs-main -fPIC -c ForeignExportCost.hs
ghc -no-hs-main -shared ForeignExportCost.o -o ForeignExportCost.a
What am I missing or doing wrong?
Ugh - it looks like the answer to my question is detailed here, telling me how to painfully add a ton of .a's to my project. And this blog post gave some helpful tips to getting on the way.
Although if someone tells me "hey wait, there's an easier way than iteratively figuring out failed deps" that would be awesome. Because I want to reuse this framework several times and this is a real pain of a way to get things up and going!

Resources