HaxeFoundation / HaxeFoundation/hxcpp
error LNK2019: unresolved external symbol: `struct hx::TLSData<struct hx::StackContext,1>hx::tlsStackContext`, ` __imp_MessageBoxA referenced in function "void __cdecl hx::CriticalErrorHandler`
- Dominant language
- C++
- Stars
- 330
- Forks
- 227
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 18
Description
Tried to download Haxe to experiment and see what the story was like for using it to author libraries which expose C ABIs + interop with C/C++:
```ps1
C:\Users\rayga\tmp\haxe\cpp>haxe --version
4.3.0-rc.1+3cb7fe4
```
Compiled the following file:
```hx
class Example {
static function main():Void {
trace("hello world");
}
}
```
To C++ using:
```hxml
-main Example
-cpp cpp/
-D static_link
-D HXCPP_VERBOSE=1
-D HXCPP_M64
# Also tried:
# -D mingw
# -D MINGW_ROOT=
```
And then to test this, I wanted to try to it out by calling:
```cpp
// cl.exe test.cpp -I"C:/HaxeToolkit/haxe/lib/hxcpp/4,2,1/include"
// clang-cl.exe test.cpp -I"C:/HaxeToolkit/haxe/lib/hxcpp/4,2,1/include"
#include
#include "./HxcppConfig-19.h"
#pragma comment(lib, "libExample.lib")
#include "./include/Example.h"
extern "C" const char *hxRunLibrary();
extern "C" void hxcpp_set_top_of_stack();
int main() {
using namespace std;
hxcpp_set_top_of_stack();
const char *err = hxRunLibrary();
if (err) {
cout << "Error: " << err << endl;
return -1;
}
cout << "Making new Example from Haxe" << endl;
auto example = new Example_obj();
cout << "Calling Example.main()" << endl;
example->main();
cout << "Finished" << endl;
return 0;
}
```
But on compilation, this gives ☹️
```ps1
test-ce60cd.obj : error LNK2019: unresolved external symbol
"struct hx::TLSData hx::tlsStackContext"
(?tlsStackContext@hx@@3U?$TLSData@UStackContext@hx@@$00@1@A)
referenced in function "public: static void * __cdecl hx::Object::operator new(unsigned __int64,bool,char const *)" (??2Object@hx@@SAPEAX_K_NPEBD@Z)
libExample.lib(b976ba10_Debug.obj) : error LNK2019: unresolved external symbol
__imp_MessageBoxA
referenced in function "void __cdecl hx::CriticalErrorHandler(class String,bool)" (?CriticalErrorHandler@hx@@YAXVString@@_N@Z)
test.exe : fatal error LNK1120: 2 unresolved externals
clang-cl: error: linker command failed with exit code 1120 (use -v to see invocation)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the Windows link step using test.cpp, HxcppConfig-19.h, the generated include/Example.h, and libExample.lib, then inspect the two unresolved symbols in the linker output. Done means determining whether the generated library or the test command is missing the required hxcpp and Windows dependencies, and documenting or correcting the supported build path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100