1

When I try to compile nlopt with Visual Studio Express 2013 using the provided Windows cmake files from the website, the configuration via cmake -DCMAKE_BUILD_TYPE=Release -DNLOPT_BUILD_SHARED=On -G"NMake Makefiles" .. in a build subdirectory works fine, but compiling via nmake fails with this error message:

[ 40%] Building C object CMakeFiles/nlopt.dir/cobyla/cobyla.c.obj
cobyla.c
e:\dev\nlopt\nlopt-2.4.1\cobyla\cobyla.c(1503) : fatal
 error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 228)
 To work around this problem, try simplifying or changing the program near the l
ocations listed above.
Please choose the Technical Support command on the Visual C++
 Help menu, or open the Technical Support help file for more information
INTERNAL COMPILER ERROR in 'c:\MSVS12\VC\bin\cl.exe'
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
NMAKE : fatal error U1077: 'c:\MSVS12\VC\bin\cl.exe' : return code '0x1'
Stop.
NMAKE : fatal error U1077: 'c:\MSVS12\VC\bin\nmake.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'c:\MSVS12\VC\bin\nmake.exe' : return code '0x2'
Stop.
ERROR: Build script of nlopt failed with errorcode 1.

2 Answers 2

4

When I tried building the CMake-generated nlopt project with VC12 (the compiler in Visual Studio 2013) in Release mode, I got a compile error C1001 in cobyla.c The fix came from https://connect.microsoft.com/VisualStudio/feedback/details/1028781/c1001-on-release-build. I needed to put a #pragma before the offending line in cobyla.c.

i__1 = nact;
#pragma loop(no_vector) //line 1503
for (k = 1; k <= i__1; ++k) {

With this fix, I did not need to remove optimization flags.

0

The problem is the optimization flag /O2 which causes cl.exe to crash. To compile cobyla.c with just /O1, perform the cmake step as usual, but then change the following file before starting nmake:

In the build directory open CMakeFiles/nlopt.dir/build.make and find the directive which builds cobyla.c.obj

There, at around line number 522 change

$(C_DEFINES) /FoCMakeFiles\nlopt.dir\cobyla\cobyla.c.obj

to

$(C_DEFINES) /O1 /FoCMakeFiles\nlopt.dir\cobyla\cobyla.c.obj

Then run nmake and it will build (while emitting the warning cl : Command line warning D9025 : overriding '/O2' with '/O1', but that is exactly what we wanted).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.