Renaud Pradenc
2011-09-19 16:41:56 UTC
Hi everyone,
I'm trying to convert a haXe application that already runs under Flash and Windows to the Mac. Therefore, I plan to convert haXe code to C++, which I'll integrate in my Objective-C/Cocoa application. I need to keep an ObjC base since I need to use Cocoa's objects to provide platform-specific features.
Now, I'm facing difficulties generating the C++ code and using it in my application.
Approach 1: Generate an executable
==================================
I tried the example given on the "Getting graphically started with haXe/C++" page.
At first, this did not compile under Mac OS 10.7 because Apple now only includes SDKs 10.6 and 10.7 and hxcpp looks for SDK 10.5. Passing -D MAC_USE_CURRENT_SDK switches the Base SDK to 10.7, which is fine, but also switches the Deployment target to 10.7, which prevents it from running under 10.6. I modified hxcpp 2,08,0's mac-toolchain.xml to use 10.6 for both the Base SDK and Deployment Target.
This generates an executable, which I don't need. Anyway I tried to include the generated C++ code into my Xcode project, but the compiler complained some symbols, like "Class", were already defined.
It did not go further because this approach demands that the C++ files are included to the Xcode projet.
Approach 2: Generate a static library
=====================================
This is the approach adopted on the iPhone platform.
My sample haXe class code:
class Test {
static function main() {
trace("Hello World !");
}
static function printMessage() {
trace("See my message !");
}
}
haxe is passed the arguments:
-cpp cpp
-debug
-main Test
-D HXCPP_M64
-D static
Now the problems:
1) The build process stops with the message:
ar -cr Test-debug.a @all_objs
ar: @all_objs: No such file or directory
If I type "ar -cr Test-debug.a all_objs" (notice the absence of @), the build seems to complete, and I get a Test-debug.a file which is a text file with contains the names of the paths to the .o files.
2) Now, I'm unable to use the library within the Xcode project. I get this error message:
ld: warning: ignoring file Test-debug.a, file was built for archive which is not the architecture being linked (x86_64)
Question:
========
Does anyone know how I could turn the object files to a valid static library ?
Did anyone managed to create a static lib for Mac OS X ?
Thanks in advance !
Renaud Pradenc
Ceroce.com
I'm trying to convert a haXe application that already runs under Flash and Windows to the Mac. Therefore, I plan to convert haXe code to C++, which I'll integrate in my Objective-C/Cocoa application. I need to keep an ObjC base since I need to use Cocoa's objects to provide platform-specific features.
Now, I'm facing difficulties generating the C++ code and using it in my application.
Approach 1: Generate an executable
==================================
I tried the example given on the "Getting graphically started with haXe/C++" page.
At first, this did not compile under Mac OS 10.7 because Apple now only includes SDKs 10.6 and 10.7 and hxcpp looks for SDK 10.5. Passing -D MAC_USE_CURRENT_SDK switches the Base SDK to 10.7, which is fine, but also switches the Deployment target to 10.7, which prevents it from running under 10.6. I modified hxcpp 2,08,0's mac-toolchain.xml to use 10.6 for both the Base SDK and Deployment Target.
This generates an executable, which I don't need. Anyway I tried to include the generated C++ code into my Xcode project, but the compiler complained some symbols, like "Class", were already defined.
It did not go further because this approach demands that the C++ files are included to the Xcode projet.
Approach 2: Generate a static library
=====================================
This is the approach adopted on the iPhone platform.
My sample haXe class code:
class Test {
static function main() {
trace("Hello World !");
}
static function printMessage() {
trace("See my message !");
}
}
haxe is passed the arguments:
-cpp cpp
-debug
-main Test
-D HXCPP_M64
-D static
Now the problems:
1) The build process stops with the message:
ar -cr Test-debug.a @all_objs
ar: @all_objs: No such file or directory
If I type "ar -cr Test-debug.a all_objs" (notice the absence of @), the build seems to complete, and I get a Test-debug.a file which is a text file with contains the names of the paths to the .o files.
2) Now, I'm unable to use the library within the Xcode project. I get this error message:
ld: warning: ignoring file Test-debug.a, file was built for archive which is not the architecture being linked (x86_64)
Question:
========
Does anyone know how I could turn the object files to a valid static library ?
Did anyone managed to create a static lib for Mac OS X ?
Thanks in advance !
Renaud Pradenc
Ceroce.com
--
haXe - an open source web programming language
http://haxe.org
haXe - an open source web programming language
http://haxe.org