Unsolved Qt/C++ with Microsoft C++ - C1190: managed targeted code requires a '/clr' option
-
Hi; I compiled managed code with Microsoft C++ compiler in Qt Creator but I get this error message: error: C1190: managed targeted code requires a '/clr' option
How can I set this /clr option in Qt Creator? Should I put this option .pro file?
Thanks. -
in the .pro file add the line
QMAKE_CXXFLAGS += -clr
you'll probably also need:
QMAKE_CXXFLAGS_STL_ON -= -EHsc QMAKE_CXXFLAGS_EXCEPTIONS_ON -= -EHsc
-
@VRonin Thanks, but these are not running. I get still same error.
-
Clean and rebuild. Qt Creator is very bad at detecting changes in the .pro file
-
@VRonin I tried but it is not running. I created a new Qt Console Project and wrote this example code:
#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); int x = 17; int^ n = &x; return a.exec(); }
but I get this error: error: C3193: '^': requires '/clr' or '/ZW' command line option
-
could you try and download all the files (apart for the vcxproj and vcxproj.filters) from here https://github.com/VSRonin/FXhelper/tree/master/ManagedProcess and try to compile?
-
@VRonin I tried with MSVC2015, WinRT arm and Windows Runtime 32 bit, I get this warning: Project WARNING: Prefix not set, install will not work
But When I compiled project I saw empty console screen. -
yes, that warning is hard coded in the pro file, you can ignore it.
Since that project compiles you can use it as base. Remove my cpp and h files, add yours and compile.To get rid of the warning remove the section
isEmpty(PREFIX){ warning("Prefix not set, install will not work") } else{ target.path = "$$PREFIX" INSTALLS += target }
in the pro file
-
@VRonin I put this code in the main.cpp file: Console::WriteLine("Hello World!");
But I see empty black console screen. -
did you change the .pri file to include such main.cpp file?