Hi,
I am trying to use the NOMAD (an optimization software) library in C++. I am using Visual Studio 2010.
I got error LNK2001 error. I have #include "nomad.hpp". Can anyone help me what I am missing?
In the NOMAD handbook, the following is written. If you are using Visual C++, your programs will not link with this version of the library and you must compile the library yourself. I don't know what it means? Can someone help please?
The reason you are getting this error is that as well as including the header file (these are often mostly declarations), you must link the corresponding libraries (which usually contain the actual implementations/definitions of functions, etc.).
However, from what you say it look like you cannot link the existing library binaries. This probably means that you have to take the source files of the NOMAD library and compile/build them yourself, just you like would one of your own C++ projects.
Perhaps you can find instructions on how to do this on Google? Is there a makefile with the NOMAD files?
Thx Xander312. The code that I am using is one of the example codes coming with the NOMAD installation so I do not think the problem is with the definitions of corresponding libraries.
Yes there is a makefile, though I tried to use it using cmd but could not make it worked. After NOMAD installation, nomad.hpp and nomad.cpp files are saved. I tried to compile it with a C++ project, it was successfully compiled but what else I should do? I also saved the nomad.hpp to the source code's directory. Still did not work...
So you have compiled the NOMAD project? In that case you need to:
1) Find the library files resulting from this build (.lib extension for MSVC)
2) Add these files to your link libraries list in your active project: "Project -> Properties -> Configuration Properties -> Linker -> Input" and then click "Additional Dependencies", and finally click the arrow on the right and "Edit"
Then you can add additional link libraries - add the NOMAD ones.
You will also need to add the library paths to your VC++ directories.
There are bunch of error codes, I guess I have a problem about calling the library. One of the error coes is
error LNK2001: unresolved external symbol "void_cdeck NOMAD:end(void)"(? end@NOMAD@@YAXXZ).
As I said I think the issue is not related with NOMAD but I am missing somehing basic about using the libraries.
Are you linking the NOMAD library files (.lib for Visual Studio).
Just like you said in
So you have compiled the NOMAD project? In that case you need to:
1) Find the library files resulting from this build (.lib extension for MSVC)
2) Add these files to your link libraries list in your active project: "Project -> Properties -> Configuration Properties -> Linker -> Input" and then click "Additional Dependencies", and finally click the arrow on the right and "Edit"
Then you can add additional link libraries - add the NOMAD ones.
You will also need to add the library paths to your VC++ directories.
I linked the library file (nomad.lib). It exists in NOMAD folder. I did compile the nomad.hpp and nomad.cpp files. To create the library files, do I need to do anything else?
I am not sure. I might use the ones that came with NOMAD. Other than that lib file, I have only cpp and hpp files in a folder called src. I compiled those but I do not know if they are the right ones. What should I look for, in order to compile to get lib files?
Where did you get NOMAD, on a disc or as a download?
Provided you have a backup copy of it, I suggest deleting any .lib files (or .dll) files within one copy of the NOMAD files.
Then get CMake: http://www.cmake.org/
At the top, in CMake, enter the source files directory as your NOMAD root directory. And set the binaries directory to your NOMAD directory + "/build/".
At last, click configure and set your generator to "Visual Studio 10". Finally, click "Generate". Then go to the /build/ subdirectory of the NOMAD directory and find the Visual Studio *.sln file. Open it, and build the solution (possibly in debug and release configurations - you'll have to see NOMAD documentation for details).
Then link to the versions of the NOMAD binaries which are created within this /build/ folder.
Okay, then. Have a look at the NOMAD files and see if there is a CMakeLists.txt file anywhere. if you find one, you should probably provide that directory to CMake as the source files directory.
If you can't then it looks like you can't use CMake with it.
There is no CMakeLists.txt but the problem is solved thanks to Xander314 and Yusuf from Hemosoft. Here is the solution:
After creating the libraries using the cpp and hpp files, I defined the location of the created library file as additional library directories. (Project properties >> Configuration properties >> Linker >> General) Also, the created library file (lib file) is defined as additional dependencies. (Project properties >> Configuration properties >> Linker >> Input).
When I first tried it did not work. Then I installed the Service pack. Then it worked. Thanks again.