Closed javieralonso closed 7 years ago
Hi Javier, Sounds like you have an old version of SNOPT. The C/C++ interface is relatively new and the instructions on the website are for this new version. If you download the files in this repository, you just do:
./configure --with-snopt=/path/to/snopt
make; make install
make examples
This will compile the library and examples. The Fortran SNOPT library has to be compiled separately.
Thank you for the prompt reply!
I get an error: ./configure --with-snopt=.. bash: ./configure: No such file or directory
And, path/to/snopt is to the snopt folder or the lib folder?
The path is to the lib folder.
To do the configure, you have to be in the top directory of the C/C++ interface package.
Sorry, maybe I am missing something, but I believe I am in the top directectory of the interface package:
jalonso@ubuntu:~/software/snopt7/snopt-interface-master$ ls aclocal.m4 cexamples configure.ac include Makefile.in src autogen.sh config cppexamples LICENSE README.md
jalonso@ubuntu:~/software/snopt7/snopt-interface-master$ ./configure --with-snopt=../lib bash: ./configure: No such file or directory
Oh yeah. Sorry I forget the configure script needs to be created.
libtoolize -c; autoconf
should do it. And then you can do the configure.
Thanks - that run smoothly until "make examples", where I get a lot of errors such as:
sn30spec.f:(.text+0x1227): undefined reference to snread_' sn37wrap.f:(.text+0xdb32): undefined reference to
dcopy_'
Note, first it could not find the library snopt7, because the one I am getting after compiling SNOPT is named snopt, I renamed it adding the 7.
Thanks - that run smoothly until "make examples", where I get a lot of errors such as: sn30spec.f:(.text+0x1227): undefined reference to snread' sn37wrap.f:(.text+0xdb32): undefined reference todcopy'
It needs a blas library to link with. I just fixed the configure to add the blas option.
./configure --with-snopt=/path/to/snopt --with-blas=/path/to/blas
Note, first it could not find the library snopt7, because the one I am getting after compiling SNOPT is named snopt, I renamed it adding the 7.
New versions of SNOPT create a library called snopt7.
Thank you Elizabeth for your help.
I updated the code, installed blas and configured the interface with it: ./configure --with-snopt=../lib --with-blas=/usr/lib/
But, when running $make examples I get the error: jalonso@ubuntu:~/software/snopt7/snopt-interface-master$ make examples if [ ! -d ./mod ]; then mkdir ./mod; fi if [ ! -d ./cexamples ]; then mkdir ./cexamples; fi /bin/bash ./libtool --mode=link --tag=CC --quiet gcc cexamples/toyB.lo -o cexamples/toyB -L/home/jalonso/software/snopt7/snopt-interface-master/lib -lsnopt7_c -L../lib -lsnopt7 /usr/lib/ -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lgfortran -lm -lquadmath /usr/bin/ld: cannot find /usr/lib/: File format not recognized
Give it the actual blas library. This is different depending on system or user preferences so it has to be explicitly given.
Examples:
./configure --with-snopt=../lib --with-blas="-framework Accelerate"
./configure --with-snopt=../lib --with-blas="-L/usr/lib -lblas"
./configure --with-snopt=../lib --with-blas="-lblas"
./configure --with-snopt=../lib --with-blas="-lopenblas"
Thank you. One step closer. Now I get:
sn30spec.f:(.text+0x1227): undefined reference to snread_' sn30spec.f:(.text+0x13be): undefined reference to
snprnt_'
You're using an old version of SNOPT that splits up the libraries.
To make this interface work, you'll have to edit the Makefile. Look for the line with "-lsnopt7" and change it to "-lsnopt7 -lsnprnt -lsnblas". I believe those are the names of the old SNOPT libraries, but they might be different -- check the lib directory in SNOPT. Also snblas may not be needed if you are using a 3rd party blas library (although I'm not sure this is possible in old versions of SNOPT).
Thank you, I could now make the examples, but they throw errors when I run them. See below. I am guessing because our version of SNOPT7 is too old?
jalonso@ubuntu:~/software/snopt7/snopt-interface-master/cppexamples$ ./sntoya2 At line 90 of file src/sn03prnt.f Fortran runtime error: Unit number in I/O statement too large
jalonso@ubuntu:~/software/snopt7/snopt-interface-master/cppexamples$ ./sntoya * Error in `./sntoya': double free or corruption (!prev): 0x00000000014bdf30 * Aborted (core dumped)
jalonso@ubuntu:~/software/snopt7/snopt-interface-master/cppexamples$ ./sntoyB SNSPEC EXIT 80 -- insufficient storage allocated SNSPEC INFO 81 -- work arrays must have at least 500 elements Warning: unable to find specs file sntoy.spc sntoyB: src/snoptProblem.cpp:216: int snoptProblem::setIntParameter(const char*, int): Assertion `initCalled == 1' failed. Aborted (core dumped)
I was wondering if there was any solution to @javieralonso last post regarding a Fortran runtime error from sn03prnt.f.
I was able to successfully build snopt 7.4 on OSX 10.9. I can build the c++ examples, but for each get the same runtime error:
At line 94 of file src/sn03prnt.f (unit = 32767) Fortran runtime error: Unit number in I/O statement too large
This is regardless of building/running in Xcode or via command line. Any help would be appreciated. Thank you.
A followup:
Hi @beesor, yeah usually when you get errors like "Unit number in I/O statement too large", it's a 32 vs 64 bit issue. To use the C/C++ interface, you have to stick with 32 so don't use --with-64.
Hello everyone, I have a similar problem and thanks to this post I have partially resolved this problem (my version of snopt is older than actual. But I suppose the same of this post, I have the library split in libsnopt.a libblas.a libsnprint.a).
./configure --with-snopt=/path/to/snopt`
make; make install
make examples
these instruction works fine with out error or any warning.
But when I tried to execute the cppexample
./sntoya
it produce the error as follow:
dyld: Symbol not found: _snlog2_
Referenced from: /Users/tommasopino/Downloads/snopt-interface-master/lib/libsnopt7_cpp.dylib
Expected in: flat namespace
in /Users/tommasopino/Downloads/snopt-interface-master/lib/libsnopt7_cpp.dylib
Abort trap: 6
What did I wrong? Thanks Tommaso
Good day,
We have a full distribution of SNOPT and I managed to make it - following the instructions here:
That creates a library snopt_cpp but when I make the example sntoya.cc I get a bounch of errors such as: sntoya.cc:(.text+0x516): undefined reference to `snoptProblem::setProblemSize(int, int)'
I also looked at the instructions here: https://ccom.ucsd.edu/~optimizers/compile.html#c-cpp But, there is no folder $SNOPT/interfaces and make interface does not exist.
I now found this repository, but I do not see how to create the library from it. May I ask for some guidance with this issue?
Note, until now I had been using a precompiled snopt7_cpp library, but I now hit the 300 constraints limit.
Thank you for your help. Javier