OpenNN include unresolved external symbol in Visual Studio 2017 - c++

My name is Hector Perez. I am an international student from Guatemala studying Computer Science and Music. I am very interested in using OpenNN for a Computer-Music project. I have tried today to create a Visual C++ project that has the appropriate dependencies (as stated in http://www.opennn.net/documentation/building_opennn.html).
However, I think after some attempts, I realized I was probably doing something wrong. I include my procedure after the end of this message.
I would highly appreciate it if you can point me to a tutorial where it performs a project build step by step.
My procedure:
Created a C++ project in Visual Studio.
Right clicked the application folder in the Solution Explorer,
Went to Properties under VC++ Directories.
Copied the full paths for the dependencies into 'Include Directories'.
I built the project, but errors occur - as if the files are not found.
They are found if I explicitly use #include, but that's probably not the intent.
This is the kind of error I get. (JUST WAY BIGGER ! )
... SimplePatternRecognition.obj : error LNK2019: unresolved external symbol "public: void __cdecl OpenNN::NeuralNetwork::save(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?save#NeuralNetwork#OpenNN##QEBAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function main
1>...C:\Users\Owner\documents\visual studio 2017\Projects\SimplePatternRecognition\x64\Debug\SimplePatternRecognition.exe : fatal error LNK1120: 46 unresolved externals
1>Done building project "SimplePatternRecognition.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I solved it!
I put on this repository my sample code and my steps to add OpenNN to Visual Studio: Look at the README.md file.
REPOSITORY: https://github.com/HectorGit/allMyOpenNNCode

Related

How to solve 'error LNK2001: unresolved external symbol' for writing a User-defined Model (FLAC) in Visual Studio 2010 C++?

I am trying to write a User-defined Model in C++ for FLAC in Visual Studio Express 2010 C++. Initially, I am trying to run (debug and build) the built-in Strain-softening Model based on the Mohr-Coulomb criterion (Available in FLAC 8.0) by changing its name only. Once I succeed to do it, I will try to modify it as per my requirement. I am running the code in VS2010. I have already installed SDK7.1, VS2010 SP1, etc. However, I am getting the following error msg:
1>------ Build started: Project: i_ssoft, Configuration: Debug x64 ------
1> modeli_ssoft.cpp
1> Creating library C:\Program Files\Itasca\FLAC800\PluginFiles\Models\modeli_ssoft\i_ssoft\i_ssoft.lib and object C:\Program Files\Itasca\FLAC800\PluginFiles\Models\modeli_ssoft\i_ssoft\i_ssoft.exp
1>modeli_ssoft.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl models::ConstitutiveModel::getPluginName(void)const " (?getPluginName#ConstitutiveModel#models##UEBA?AV?$basic_string#_WU?$char_traits#_W#std##V?$allocator#_W#2##std##XZ)
1>C:\Program Files\Itasca\FLAC800\PluginFiles\Models\modeli_ssoft\i_ssoft\\i_ssoft.dll : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
From the error code, it is clear that I need to add some libraries or I need to place the supporting libraries in the same project directory... which I have tried but still, I am getting the error.

Unresolved external symbol _glfwInit due to 32-bit/64-bit mismatch

How do I link the library in a way that visual studio 2015 can actually see it?
Here's a few screenshot of my folders:
glfw3, glfw3/include/glfw/, glfw3/lib
I've attempted to link these folders into visual studio, under "vc++ directories => include/library directories as such: include, library
also linking the same to my project directly, under linker => input => additional dependencies
to me, that seems like everything is correct (this is how it was in the tutorial i am following, learnopengl.com)
note: I am also doing the same with the GLAD library, which that has a .c file that I put directly into my sources, along with the header files linked the same way as with GLFW.
but despite trying to run this code:
#include <glad/glad.h>
#include <GLFW/glfw3.h>
int main() {
glfwInit();
return 0;
}
it will always return this error, or similar ones:
1>------ Build started: Project: opengl_test, Configuration: Debug Win32 ------
1> main.cpp
1>main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>C:\Users\Honza\Desktop\C++ programs\lib\glfw3\lib\glfw3.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
1>c:\users\honza\documents\visual studio 2015\Projects\opengl_test\Debug\opengl_test.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm guessing there is something wrong with how I linked the libraries. I am willing to literally re-install visual studio if I have to, just please give me some possible solutions. I want to start learning opengl but all this jazz with linking libraries is leaving me frustrated and confused.
EDIT: The problem here was that I was using 64-bit GLFW binaries instead of the 32-bit ones, and compiling in 32-bit. I've fixed that, and now I get even more errors:
1>------ Build started: Project: opengl_test, Configuration: Debug Win32 ------
1>libglfw3.a(init.c.obj) : error LNK2019: unresolved external symbol ___chkstk_ms referenced in function __glfwInputError
1>libglfw3.a(init.c.obj) : error LNK2019: unresolved external symbol _vsnprintf referenced in function __glfwInputError
1>MSVCRTD.lib(vsnprintf.obj) : error LNK2001: unresolved external symbol _vsnprintf
1>libglfw3.a(context.c.obj) : error LNK2019: unresolved external symbol _sscanf referenced in function __glfwRefreshContextAttribs
1>MSVCRTD.lib(vsnprintf.obj) : error LNK2001: unresolved external symbol __vsnprintf
1>C:\Users\Honza\Documents\Visual Studio 2015\Projects\opengl_test\Debug\opengl_test.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You write that you tried to link "these folders", while in fact, you need 2 separate things in order to use a function from a static library.
Use the proper header file so compilation succeeds. From the error you quoted, compilation went well. The program knows there is an external function named _glfwInit.
Link to the specific library (.lib file). Looks like you placed a path of a folder and not the full path of the .lib file.
Under Linker => input => additional dependencies, place the full path of the gfw3.lib file.
I faced the same problem while following learnopengl.com, The issue is that you need to rebuild glfw library with cmake again,
but this time when you choose visual studio 2015 or whatever for your generator for this project, you must also choose: OPTIONAL PLATFORM FOR GENERATOR -> x64
you can make sure that every thing is OK when you build glfw inside Visual Studio and the platform that appears is x64

Code::blocks: |undefined reference to `_imp__glewExperimental] and glewGenBuffers [duplicate]

I am trying to build an opengl project in Visual Studio 2012. I wanted to statically include glew library, so I built it from source and copied the generated glew32sd.lib to my lib directory. I gave this lib path to Visual Studio and put "glew32sd.lib" to my additional dependencies in VS.
Now when I compile a sample code in main.cpp:
#define GLEW_STATIC
#include<GL/glew.h>
int main(){
glewInit();
return 0;
}
I get the following error:
1> main.cpp
1>glew32sd.lib(glew.obj) : error LNK2019: unresolved external symbol __imp__glGetString#4 referenced in function _glewGetExtension#4
1>glew32sd.lib(glew.obj) : error LNK2019: unresolved external symbol __imp__wglGetCurrentDC#0 referenced in function _wglewInit#0
1>glew32sd.lib(glew.obj) : error LNK2019: unresolved external symbol __imp__wglGetProcAddress#4 referenced in function _wglewInit#0
1>C:\Projects\OpenGL\opengl\Debug\opengl.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
In my understanding, this error should be because compiler could not find the definitions for the function call.
Here are a few relevant snapshots:
The Library dependencies of my project
Path to libs
Why could this error be coming? I tried rebuilding the solution but that didn't help either. Any suggestion would be helpful.
You have two problems in the linker settings:
You can link against the statically linked version of glew or the dynamically linked one, but never against both. So if you want glew statically linked remove glew32d.lib (or glew32.lib in release mode) from the additional dependencies.
Glew requires you to also link agains the opengl library. Add OpenGL32.lib to the additional dependencies.

Error in Visual studio 2015 after installing SFML

recently I've installe SFML for Visual studio 2015. I have read the tutorial for this specific task on there web site but after the test (compiling and running debug) this error show up:
https://pastebin.com/mY7r7zy9
1>------ Build started: Project: projet game, Configuration: Debug Win32 ------
1> main.cpp
1>MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main##YAHXZ)
1>C:\Users\Cewein\documents\visual studio 2015\Projects\projet game\Debug\projet game.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
why and what should i do ?
should i rename my main.cpp to winmain.cpp ?
thanks you for the help
P.S: VS2015 is one the main drive where the OS is (C:) but SFML the folder is on another drive (E:)
If your subsystem is set to Windows (/SUBSYSTEM:WINDOWS), you need to link sfml-main, which will define WinMain() and call main().
If your subsystem is set to Console (/SUBSYSTEM:CONSOLE), then you don't need to link sfml-main.
To change the subsystem, go to your project settings, then Properties -> Linker -> System -> SubSystem

Installing Glog linking error

I am new to programming. I want to install Glog on my Windows 10 system. I have followed the instructions found in a Stack Overflow thread with the same name.
I used cmake and Visual Studio 2015 to build the project.
First anomaly of the built file: I noticed that in the glog directory the header file "log_severity.h" was missing. To alleviate this problem, I copied the "log_severity.h" from the GitHub repository and pasted it.
http://imgur.com/QeLTnat
I then created a sample program that just initializes the logger by only using
google::InitGoogleLogging(argv[0]);
in the main.
Before compiling I direct the linker to include an additional include directory. This include directory is the one with the header files as in the second image (with the log_severity.h etc.):
http://imgur.com/yrjOIot
Yet I still receive a linking error when compiling the code:
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl google::InitGoogleLogging(char const *)" (__imp_?InitGoogleLogging#google##YAXPEBD#Z) referenced in function main
1>D:\Documents\Programming\C++\Programme\GLogTest\GlogTest\x64\Debug\GlogTest.exe : fatal error LNK1120: 1 unresolved externals
What am I doing wrong?
Thanks a lot of any answers.
I solved it. When you build the project in visual studio, there is also an "Installation" folder inside the MS project. I forgot to build that as well!