Closed skylerparr closed 2 years ago
I locally patched the HaxeCBridge.hx
and got rid of the build errors. Testing the library to see if my changes worked.
Thanks for testing @skylerparr :), I've so far only tested on macOS with clang 11 (and there I get no errors) but it's useful to know about the errors on windows and linux: looks like there's some windows-specific thread code that I haven't taken care of properly! At a glance it looks like I'm missing some #ifdef windows around some non-windows thread code
With haxeThreadNativeHandle = nullptr
, we're safe to remove the = nullptr
I'm away from my PC but over the weekend I'll run the unit test on windows
Still trying to verify windows. But, I was able to create a PR for the fix for Linux with a readme that describes some issues I had and how I solved them for my specific versions.
I created this PR that successfully builds for windows. But, the unit test still doesn't compile. On my first attempt I got:
.\app.c(7): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
So I commented out the include, then got this build error:
.\app.c(176): error C2065: 'CLOCK_REALTIME': undeclared identifier
.\app.c(180): error C2065: 'CLOCK_REALTIME': undeclared identifier
.\app.c(212): error C2065: 'CLOCK_REALTIME': undeclared identifier
.\app.c(215): error C2065: 'CLOCK_REALTIME': undeclared identifier
So I defined the CLOCK_REALTIME as a constant to get around that error, so now I'm down to a more telling error:
app.obj : error LNK2019: unresolved external symbol _HaxeLib_initializeHaxeThread referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_stopHaxeThreadIfRunning referenced in function _onHaxeException
app.obj : error LNK2019: unresolved external symbol _HaxeLib_releaseHaxeString referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_releaseHaxeObject referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeNoArgsNoReturn referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_callInMainThread referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_callInExternalThread referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_add referenced in function _fnVoid
app.obj : error LNK2019: unresolved external symbol _HaxeLib_starPointers referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_rawPointers referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_hxcppPointers referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_hxcppCallbacks referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_externStruct referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_allocateABunchOfData referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_allocateABunchOfDataExternalThread referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_enumTypes referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_checkHaxeAnon referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_checkAnonFromPointer referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_createHaxeMap referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_checkHaxeMap referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_checkNull referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_createCustomType referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_createHaxeString referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_checkHaxeString referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_throwException referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Main_stopLoopingAfterTime_ms referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Main_getLoopCount referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Main_hxcppGcMemUsage referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Main_hxcppGcRun referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Main_printTime referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Instance_new referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Instance_methodNoArgs referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Instance_methodAdd referenced in function _main
app.obj : error LNK2019: unresolved external symbol _HaxeLib_Instance_overrideMe referenced in function _main
app.obj : error LNK2019: unresolved external symbol _sleep referenced in function _main
app.obj : error LNK2019: unresolved external symbol _clock_gettime referenced in function _main
app.exe : fatal error LNK1120: 38 unresolved externals
Which is a much more telling set of errors that looks like something still isn't right. My C++ isn't great, so there could be some other things I'm messing up. This is my build command I'm using from powershell:
cl .\app.c /I .\haxe-bin\ .\haxe-bin\obj\lib\Main-debug.lib
I'm not 100% confident that this is the correct way to compile the program, so that could be the issue on its own. I hope this is useful for you to help get this working on Windows. LMK if there's anything else I can help with or look into to get this working.
Gotcha, this looks good :). The test code app.c
is written against unixy libs for things like timestamping, not a big thing to swap to the windows alternatives there so that's easy to fix
The unresolved symbols error is saying that it's not linking against the generated library – I need to check docs to learn how cl.exe does things but I expect just a small tweak to compiler args
Should be good now :), try run.win.cmd for a working windows example
Hello. This is a really cool project. This is something I really need. Unfortunately, I'm running into some build errors on the example and I'm currently stuck.
here's my setup: Windows 10
build.hxml
deps/haxe-c-bridge is a clone of master
hxcpp version:
Main.hx code:
My build error
Getting a build error on Linux too, but I'm less concerned about Linux not working, but here it is anyway:
LMK if you have any clues. I'll be trying to debug on my end and if I find something I'll push up a PR.
Thanks again for the cool library.