SDK compatibility issues in VS2019 C++ project with std::string
SDK compatibility issues in VS2019 C++ project with std::string
Hi,
i'm new to this forum, and to LuxCore!
I registered because I'm working to integrate LuxCore renderer into another c++ software as a test, but i'm encountering few issues with the distributed builds of the SDK, I also tried to re-build to no avail:
What i did to rebuild:
git clone https://github.com/LuxCoreRender/LuxCore
git clone https://github.com/LuxCoreRender/WindowsCompile
and then in the visual studio 2019 console:
.\cmake-build-x64.bat /dll /debug /vs2019
following the tutorial found here:
https://github.com/LuxCoreRender/WindowsCompile
The build works fine, i also tried the compiled luxcoreui.exe to launch some test scenes and it works!
The issue is that when i try to use the luxcore.DLL in my project, std::string create corruption, e.g. :
PropertyValue propVal = 6; // works fine!
PropertyValue propVal = "test string"; // propVal is corrupted....
This is probably due to some incompatibility / alignment issue with how my project is build...
I was also reading this topic: viewtopic.php?t=1013 where another user had similar issues, but it's not clear if he solved or not.
My project is using the same platform tooset (v142) used fo the build and i tried with both debug and release builds, what do you think is causing the issue? Any suggestion would be very much appreciated!
i'm new to this forum, and to LuxCore!
I registered because I'm working to integrate LuxCore renderer into another c++ software as a test, but i'm encountering few issues with the distributed builds of the SDK, I also tried to re-build to no avail:
What i did to rebuild:
git clone https://github.com/LuxCoreRender/LuxCore
git clone https://github.com/LuxCoreRender/WindowsCompile
and then in the visual studio 2019 console:
.\cmake-build-x64.bat /dll /debug /vs2019
following the tutorial found here:
https://github.com/LuxCoreRender/WindowsCompile
The build works fine, i also tried the compiled luxcoreui.exe to launch some test scenes and it works!
The issue is that when i try to use the luxcore.DLL in my project, std::string create corruption, e.g. :
PropertyValue propVal = 6; // works fine!
PropertyValue propVal = "test string"; // propVal is corrupted....
This is probably due to some incompatibility / alignment issue with how my project is build...
I was also reading this topic: viewtopic.php?t=1013 where another user had similar issues, but it's not clear if he solved or not.
My project is using the same platform tooset (v142) used fo the build and i tried with both debug and release builds, what do you think is causing the issue? Any suggestion would be very much appreciated!
Re: SDK compatibility issues in VS2019 C++ project with std::string
May be a problem related to UTF-8 Vs UTF-16 ? Does VS2019 something strage with std::string ? Like using std::wstring instead ?
Re: SDK compatibility issues in VS2019 C++ project with std::string
Thanks for your reply!
I think that should actually be fine, since to test it i created an empty c++ project, in which i just copied the luxcoredemo.cpp test code from the luxcoredemo project, slightly modified to avoid using boost, here is the code: , std::string should be the same...
I think that should actually be fine, since to test it i created an empty c++ project, in which i just copied the luxcoredemo.cpp test code from the luxcoredemo project, slightly modified to avoid using boost, here is the code: , std::string should be the same...
Re: SDK compatibility issues in VS2019 C++ project with std::string
I think you are referring to the output of this:
What do you get as output when the value is corrupted?
I did a naive test, building luxcoredemo with VS2017 and VS2019 and comparing the output.
They are identical and look both strange to me, but I could be wrong as I don't know so well the Luxcore API.
From these lines in luxcoredemo.cpp:
I would imagine to get this output:
Dade, is this correct?
This is what I get instead, with both Visual Studio versions:
Code: Select all
PropertyValue propVal = "test string";
Property prop("test1.prop1", propVal);
cout << "test1.prop1[0] => " << prop.Get<string>(0) << "\n\n";
I did a naive test, building luxcoredemo with VS2017 and VS2019 and comparing the output.
They are identical and look both strange to me, but I could be wrong as I don't know so well the Luxcore API.
From these lines in luxcoredemo.cpp:
Code: Select all
Property prop("test1.prop1", "aa");
cout << "test1.prop1[0] => " << prop.Get<string>(0) << "\n\n";
Code: Select all
test1.prop1[0] => aa
This is what I get instead, with both Visual Studio versions:
Code: Select all
test1.prop1[0] => 1
Re: SDK compatibility issues in VS2019 C++ project with std::string
Hello MMatteini,
looks like you run into the same problem as I did. I assume you work with the Debug configuration of VS. In this case the _DEBUG switch is active which leads to some modifications to the STL components by introducing additional security checks by MS. This makes your code incompatible with libraries not compiled with this switch (like luxcore especially in Release builds) due to different memory layout of objects. I solved it by also removing the _DEBUG switch in my interface library and using boost::string to transfer strings to this library. In my case luxcore works then without problems.
Hope this helps also in your case. Feel free to ask for more details.
looks like you run into the same problem as I did. I assume you work with the Debug configuration of VS. In this case the _DEBUG switch is active which leads to some modifications to the STL components by introducing additional security checks by MS. This makes your code incompatible with libraries not compiled with this switch (like luxcore especially in Release builds) due to different memory layout of objects. I solved it by also removing the _DEBUG switch in my interface library and using boost::string to transfer strings to this library. In my case luxcore works then without problems.
Hope this helps also in your case. Feel free to ask for more details.
Re: SDK compatibility issues in VS2019 C++ project with std::string
Hi, thanks for your tests!
Unfortunately i don't even get that far, since after:
Code: Select all
Property prop("test1.prop1", "aa");
Hi Ernest, I was hoping to know how you solved! your problem was indeed similar. The _DEBUG switch is the first thing i tried after reading your post, actually I copy/replaced all the preproc definitions in my project to match the ones from luxcore, just to be sure, I also tried to build both luxcore and my project in Debug and the Release, but no combination of the above worked...
Which toolset did you end up using? (I'm building with v142)
Re: SDK compatibility issues in VS2019 C++ project with std::string
That is also what I am seeing: that piece of data is recognized as BOOL_VAL, and then the corresponding output is:
Code: Select all
test1.prop1[0] => 1
Yesterday I compiled it also in a Linux VM and result is the same.
One thing I have seen is that, later in the luxcoredemo.cpp code, other string examples are handled with the "string" type:
Code: Select all
// String tests
const string testStr("TEST123");
Property p0("string.test", testStr);
I am not sure if this makes sense, please forgive my little knowledge of C++
Re: SDK compatibility issues in VS2019 C++ project with std::string
"aa" is "char *" while std::string is a different type, do you get the same error if you use something like "string("aa")" instead of "aa" ?
Re: SDK compatibility issues in VS2019 C++ project with std::string
I tried, and unfortunately i do...
I put toghether the most minimal VS2019 project that include an SDK build to show the issue, i'll attach it to this post, you only have to replace lib/ and include/ folders with the ones from the sdk build (i didn't inlcude my build to keep the size small, but the 2.4 sdk from the download section show the same issue).
I just created a new console project, added includes and luxcore.lib, and removed _DEBUG as suggested by Ernest!
If i can make this minimal test work, by either creating a compatible sdk build, or adjusting the test project my issue is solved
- Attachments
-
- LuxcoreSdkMinimalTest.zip
- (30.07 KiB) Downloaded 155 times
Re: SDK compatibility issues in VS2019 C++ project with std::string
I also tried and it's working here, both VS2017 and VS2019.
Code:
Code: Select all
Property prop("test1.prop1", string("aa"));
cout << "test1.prop1[0] => " << prop.Get<string>(0) << "\n\n";
Code: Select all
test1.prop1[0] => aa
I will test with your project as soon as possible.