The reason you get that SIGSEGV error is because the `SayHello` function in 
your C++ code prints "Hello world" but has a void return type, so it doesn't 
return anything. Then you import that as saying it returns a `cstring` (which 
is a pointer to an array of character) and try to print that out. This will 
obviously not work as the pointer will not point to anything in particular.

That being said what you could do instead (which is the normal thing to do and 
probably why you haven't found much good data on your approach) is to build the 
C++ library into your Nim project. So instead of first compiling your C++ code 
into a DLL, then load that on runtime in Nim from memory you can instead simply 
build your Nim project together with the C++ project so that it's all one big 
project. This would likely have caught your bug as well because GCC would 
complain that the `SayHello` function didn't return anything. This can be done 
like this for example: 
<https://github.com/PMunch/badger/blob/master/pgmspace.nim#L3-L10>

Reply via email to