Compile Fortran to mex on Mac - macos

I have been forced to return to an old bugbear lately: compiling a fortran script to run under Matlab on Mac. I have managed to compile the example c file to mex but the Fortran file refuses unless I use -c and the object of my desire, kt3d.for, throws up a whole list of fun but all linked to the same error (I guess).
I'm running Matlab R2011b on OSX 10.7.5 with XCode 4.6.1.
I've patched Matlab according http://www.mathworks.se/support/solutions/en/data/1-FR6LXJ/
Got a Fortran compiler running according to https://sites.google.com/site/dwhipp/tutorials/mac_compilers
I altered the mex file to call bash rather than sh but still no joy. Getting tired of having to boot up my old XP machine every time I want to run a kriging package so I would really like to compile these things for OSX.
Below is the error, it looks like an architecture issue but I cant figure out how to fix it.
>> mex kt3d.for
Undefined symbols for architecture x86_64:
"_chknam_", referenced from:
_readparm_ in kt3d.o
"_cova3_", referenced from:
_kt3d_ in kt3d.o
"_ktsol_", referenced from:
_kt3d_ in kt3d.o
"_mexfunction_", referenced from:
-exported_symbol[s_list] command line option
"_picksup_", referenced from:
_kt3d_ in kt3d.o
"_setrot_", referenced from:
_kt3d_ in kt3d.o
"_setsupr_", referenced from:
_kt3d_ in kt3d.o
"_srchsupr_", referenced from:
_kt3d_ in kt3d.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
mex: link of ' "kt3d.mexmaci64"' failed.
Error using mex (line 206)
Unable to complete successfully.

I believe those symbols are found in GSLIB. Assuming you have this installed and somewhere that your compiler can find it, you may need to add something like "-lgslib" to your mex command to get it to link the library for you.

Related

How do I compile tree-sitter parsers?

I'm trying to compile the typescript, tsx, and python parsers for use with neovim, but when I run gcc -o parser.so -shared src/parser.c -Os -I./src as instructed by the tree-sitter tracking issue I get:
Undefined symbols for architecture x86_64:
"_tree_sitter_tsx_external_scanner_create", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
"_tree_sitter_tsx_external_scanner_deserialize", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
"_tree_sitter_tsx_external_scanner_destroy", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
"_tree_sitter_tsx_external_scanner_scan", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
"_tree_sitter_tsx_external_scanner_serialize", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.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've run the npm build steps, and tried the make file in build, but I'm not able to get the final .so files.
the error undefined symbol: tree_sitter_parsername_external_scanner_create also appears, when there is a mismatch between parser name and function names
// grammar.js
name: 'parsername',
// scanner.cc
void *tree_sitter_oldparsername_external_scanner_create() {
return new Scanner();
}
quickfix: replace name in scanner source
sed -i -E 's|(tree_sitter)_oldparsername_|\1_parsername_|g' src/scanner.*
Some grammars have external scanners - hand written C/C++ source files that are by convention called scanner.c or scanner.cc, which need to be compiled along with parser.c.

Integrating OSRM Code with XCode Application

I am trying to link Open Source Routing Machine (OSRM) code with a basic command-line application in XCode and run the code provided in Example.cpp (from osrm-master directory) as the main function. I am able to link header files from OSRM 'include' as well as all other required libraries, so within the code, there are no identified errors. However, when I run the project, I get the following error:
Undefined symbols for architecture x86_64: "osrm::OSRM::OSRM(osrm::engine::EngineConfig&)", referenced from: _main in main.o "osrm::OSRM::~OSRM()", referenced from: _main in main.o "osrm::OSRM::Route(osrm::engine::api::RouteParameters const&, osrm::util::json::Object&) const", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64
Why might this be and how could I approach solving this error? Is there a way you could recommend to link OSRM file system into my application? I don't want to link the library itself (libosrm.a), but the actual source code files.

A build error occurred when I used Xcode to compile a example 'sync_client' of boost

I used Xcode to build a example of boost, but as you see followed it is failed. And the error
I've got is:
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
___cxx_global_var_init2 in sync_client.o
boost::asio::error::get_system_category() in sync_client.o
boost::system::error_code::error_code() in sync_client.o
"boost::system::generic_category()", referenced from:
___cxx_global_var_init in sync_client.o
___cxx_global_var_init1 in sync_client.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 don't know how I can fix it. I've added the include and libs path of boost into Xcode Build Setting. Does anyone have any idea about this problem?
Either link against a pre-built version of libboost-system.so or pull in libs/system/src/error_code.cpp (from your boost source package), into your project.

Zxing 'undefined symbols for architecture x86-x64' error

I use zxing lib in my OS X application. I've included zxing-objc to my project and simply copy-pasted code from zxing demo (zxing-root/objc/examples/demo) to the separate ViewController class. When trying to compile project, I get the following linker errors:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_QTCaptureDevice", referenced from:
objc-class-ref in ScanViewController.o
"_OBJC_CLASS_$_ZXCapture", referenced from:
objc-class-ref in ScanViewController.o
"_QTMediaTypeMuxed", referenced from:
-[ScanViewController performVideoSourceScan] in ScanViewController.o
"_QTMediaTypeVideo", referenced from:
-[ScanViewController performVideoSourceScan] in ScanViewController.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've carefully checked all code and compared my project properties (including c++ compiler options) to demo project properties, and everything is done right.
You need to add the necessary frameworks to your app target. You can look in the sample app for an example. Select the target in Xcode, select Build Phases, and open the Link With Libraries entry. You'll see that it includes both QuartzCore and zxing-objc-framework. It sounds like you don't have those in your project.

Is there a way to use GrowlApplicationBridge without NSClassFromString?

I'm trying to build a basic cocoa app that uses Growl.
Every time I want to use GrowlApplicationBridge I have to use something like
Class GAB = NSClassFromString(#"GrowlApplicationBridge");
[GAB performSelector:#selector(setGrowlDelegate:) withObject:self];
I would like to be able to just use
[GrowlApplicationBridge setGrowlDelegate:self];
Here's the compiler error that I get when I try the behavior that I want:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GrowlApplicationBridge", referenced from:
objc-class-ref in StatusMenuAppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
As long as you're importing <Growl/Growl.h> at the top of that file and linking the framework into your app, you should be able to use [GrowlApplicationBridge setGrowlDelegate:self] just fine.
Check the top of the file and make sure you're importing it, and check your target's “Link Libraries and Frameworks” build phase and make sure you're linking it.

Resources