I downloaded the sdk and ran the Windows related commands described here.
Then I created a new VC++ project and copied the contents of a tutorial file included with that sdk (t1.cpp).
There were compile time errors, which I fixed by including the path to gmsh.h in the include settings found in projcet->Properties->Configuration Properties->C/C++->General->Additional Include Directories.
I also included path to the gmsh.lib file at projcet->Properties->Configuration Properties->Linker->General->Additional Libraries Directories.
Still I am getting the below error while trying to build the project:
LNK2019: unresolved external symbol gmshFree referenced in function "int __cdecl gmsh::model::geo::addCurveLoop(class std::vector<int,class std::allocator<int> > const &,int,bool)" (?addCurveLoop#geo#model#gmsh##YAHAEBV?$vector#HV?$allocator#H#std###std##H_N#Z)
Please say what I am missing here. I am running Microsoft Visual Studio Community 2019 (Version 16.10.4) on Windows 10.
Did you add #include "gmsh.h " and add gmsh.lib in Configuration Properties > Linker > Input? For more information, you could refer to the document: Create a client app that uses the DLL.
Related
In my on my header file (pages.h), I've done:
#include "mat.h".
In my cpp, all I'm trying to do is a simple:
MATFile *pmat.
However, whenever I try to build my code, I get an error that says:
1>pages.obj : error LNK2019: unresolved external symbol _matOpen referenced in function "public: void __thiscall DataPage::LoadDBIData(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadDBIData#DataPage##QAEXV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
and
1>C:\Users\celes\source\repos\bci2000-svn\tools\P300Classifier_electrode_selection\P300Classifier_electrode_selection.exe : fatal error LNK1120: 1 unresolved externals
I've tried going into Properties->C/C++->General->Additional Include Directories and adding a file path of C:\Program Files (x86)\MATLAB\R2015b\extern\include", but I am still receiving the same error. Without this included path, I only received the second error, not the first one.
I am using Visual Studio 2010 (it's for an old research lab) and R2015b for MATLAB.
Any sort of help would be appreciated!
The error message indicates that the compiler has trouble resolving the symbol. Apparently, you didn't set up the project correctly. Besides the "Additional Include Directories" option, you also need to set the library directory in the Linker-> Additional Library Directories for using an external library.
Because you are running a project in VS C++, you will need to have $(MATLABPATH)\extern\lib\<arch>\microsoft in that option, where $(MATLABPATH) is "C:\Program Files (x86)\MATLAB\R2015b" and the <arch> might be Win64 or Win32 depending on your target machine flag in your VS project (i.e. 32- or 64-bit).
Firstly, you could check if you add C:\Program Files (x86)\MATLAB\R2015b\extern\include in Porperties->VC++ Directories-> Include Directories, C:\Program Files (x86)\MATLAB\R2015b\extern\lib\winXX\microsoft in Porperties->VC++ Directories->Library Directories.
Secondly, you could check if you add libmat.lib;ibeng.lib;libmx.lib in Porperties->Linker->Input->Additional Dependencies.
Finally, you could refer to Microsoft Docs about LNK2019 and LNK1120.
I installed and integrated latest version of vcpkg:
e:\work\vcpkg>vcpkg version
Vcpkg package management program version 0.0.65-692a363701156f1bc319306fbde93fb6748325f6
See LICENSE.txt for license information.
e:\work\vcpkg>vcpkg integrate install
Applied user-wide integration for this vcpkg root.
All C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.
I installed google test:
e:\work\vcpkg>vcpkg list
gtest:x64-windows 1.8 GoogleTest and GoogleMock testing frameworks.
gtest:x86-windows 1.8 GoogleTest and GoogleMock testing frameworks.
I included gtest.h in my project in Visual Studio 2015 Update 3:
#include <gtest/gtest.h>
It compiles fine, but I have linker errors:
1>main.obj : error LNK2001: unresolved external symbol "void __cdecl testing::InitGoogleTest(int *,char * *)" (?InitGoogleTest#testing##YAXPEAHPEAPEAD#Z)
1>main.obj : error LNK2001: unresolved external symbol "public: int __cdecl testing::UnitTest::Run(void)" (?Run#UnitTest#testing##QEAAHXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: static class testing::UnitTest * __cdecl testing::UnitTest::GetInstance(void)" (?GetInstance#UnitTest#testing##SAPEAV12#XZ)
Apparently, Visual Studio does not know it should link with gtest.lib. And I cannot understand why. Vcpkg only says that "Linking will be handled automatically." No idea how it is going to do this.
In "Additional Library Dependencies" of my project I can see these inherited values:
$(VcpkgRoot)lib
$(VcpkgRoot)lib\manual-link
And $(VcpkgRoot) is resolved to e:\work\vcpkg\installed\x64-windows\. So it seems like integration was successful. But how Visual Studio knows it should link with gtest.lib?
Note that if I add gtest.lib to "Additional Dependencies" manually, all works fine, and gtest.dll is automatically copied to output directory.
I think that the autolinking behavior has been intentionally disabled for gtest, see vcpkg issue #306.
Original comment on the issue: here.
The vcpkg implementation requires manual linking because Google Test can redefine main(), and the gtest functionality is duplicated in all of the four separate library files.
Official documentation.
The required per project configuration:
In: Configuration Properties > Linker > Input > Additional Dependencies
For release-builds:
$(VcpkgRoot)lib\manual-link\gtest_main.lib
For debug-builds:
$(VcpkgRoot)debug\lib\manual-link\gtest_main.lib
If you want to create your own custom main(), replace gtest_main.lib with gtest.lib.
If you want to use gmock, you can replace it with gmock_main.lib or gmock.lib.
This is an old thread but I would like to point out what I've found.
You need to link the libs in the manual-link directory, but you need to link them in the right order.
First link gmock_main then gtest_main.
The other way around just results in 0 test.
I'm trying to create a .dll with Visual Studios 2013. The project includes libpq functionality.
Per other stackoverflow posts, and other sources I've found on the internet, I've (as far as I'm aware) correctly added the postgres lib and include directories to the project. However, when I go to build the project, it returns a number of "unresolved external symbol" errors.
My paths are C:\Program Files\PostresSQL\9.3\... so I have them surrounded by quotation marks in the Additional Library/Include Directory fields. I've included the libpq-fe.h header file in the project... I'm just not sure what I'm doing wrong.
Another note, I can compile a test program from the command line using g++ with the -I, -L, and -lpq flags, but I'm not sure how to compile to a .dll from the command line (plus it adds complexity that I just don't want to deal with).
These are the specific errors I'm getting:
1>sql_arma.obj : error LNK2001: unresolved external symbol _PQconnectdb
1>sql_arma.obj : error LNK2001: unresolved external symbol _PQstatus
1>sql_arma.obj : error LNK2001: unresolved external symbol _PQerrorMessage
1>sql_arma.obj : error LNK2001: unresolved external symbol _PQfinish
1>C:\Users\tills13\documents\visual studio 2013\Projects\sql_arma\Release\sql_arma.dll : fatal error LNK1120: 4 unresolved externals
I have, as suggested below, included #pragma comment(lib, "libpq.lib") in the source file for my project, I still receive these errors.
I've successfully compiled the sample program by setting these project properties:
Add <pgsql install path>\include and \lib to VC++ Directories->Include and ->Library, correspondingly
Add libpq.lib to Linker->Input->Additional dependencies
This is the standard way to reference 3rd-party libs. It's just that they recommend using environment variables for their "base dirs" to avoid patching the project when it's under a VCS.
To be able to run the app from VS (both with and without debugging), I also specified PATH=%PATH%;<pgsql install path>\bin in Debugging->Environment since this dir isn't in PATH on my system.
It's not sufficient add the postgres lib directory to the project, you must also add
reference to libpq.lib. Just add this line to one of your source .cpp files:
#pragma comment(lib, "libpq.lib")
As noted by Marco A. the library must match a program bitness (32 or 64 bit): if you build 32-bit DLL (referred as Win32) you must use 32 bit library; if 64-bit (x64) - 64-bit library.
I have also faced same issue. Then I realized that I was building my application as a 32bit. I changed the target of my application to x64 and it compiled successfully
I am trying to write C++ classes/functions which can be accessed from Lua.
I need to export the C++ library as dll files.
I'm using Microsoft Visual C++.2010 Express
So I create a project and add the require .cpp files and .h files
Now when I try to build, the following error occurs.
mylib.obj : error LNK2019: unresolved external symbol _lua_settop
referenced in function "void __cdecl g_initializePlugin(struct
lua_State *)" (?g_initializePlugin##YAXPAUlua_State###Z)
Similar errors occur for all lua functions. When Googling I learnt that I had to link LUA.
How can that be done in Visual C++.
P.S
I found a solution which directed me to give
#pragma comment( lib, "lua5.1" )
For this solution, it requires a lua5.1 file. From where should I download that file and where should it go (in the project folder?) ?
OK! I figured out how!
To link Lua, the following has to be done after the C++ project has been created.
Copy C:\Program Files\Lua\5.1\lib\lua5.1.dll to your project folder
Copy C:\Program Files\Lua\5.1\lib\lua5.1.lib to your project folder
Right Click on Project --> Properties --> Configuration Properties
--> Linker --> Input.
Add lua5.1.lib to Additional Dependencies
Right Click on Project --> Properties --> Configuration Properties
--> VC++ Directories.
Add C:\Program Files\Lua\5.1\include to Include Directories
NOTE : my lua installation is in C:\Program Files\Lua\5.1
Now on building the project, dll file is created!
I am the very bignner for the OpenCV.
I’ve just install the OpenCV and make the C++ program as follow.
My compiler is visual C++ 2008.
# include "highgui.h"
void main() {
IplImage* img = cvLoadImage("C:/OpenCV/samples/cpp/tutorial_code/images/lena.png",-1);
cvNamedWindow("lena",0);
cvShowImage("lena",image);
cvWaitKey(0);
cvReleaseImage(&image);
}
But it could not be built with the error message, and I cannot solve this problem.
The error message is as follow.
(My compiler is Korean Version and I translate the error message into English.
And the English is poor, but you may understand how it was processed.)
1>------ begin build: project: image1st,: Debug Win32 ------
1> compiling)
1>image1st.cpp
1>c:\vs2008\ccp_file\image1st\image1st.cpp(17) : warning C4700: not inetialized ‘image’ use local variable
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>linking
1>image1st.obj : error LNK2019: _cvReleaseImage External Symbol(refrence positon: _main function) not defined.
1> image1st.obj : error LNK2019: _cvWaitKey External Symbol(refrence positon: _main function)not defined.
1> image1st.obj : error LNK2019: _cvShowImage External Symbol(refrence positon: _main function)not defined.)
1> image1st.obj : error LNK2019: _cvNamedWindow External Symbol(refrence positon: _main function)not defined.)
1>image1st.obj : error LNK2019: _cvLoadImage External Symbol(refrence positon: _main function)not defined.)
1>project: warning PRJ0018 : can not find the next environment variable.
1>$(OPENCV_DIR)
1>image1st – errors: 6, warning: 1
And I modified the visual c++ environment are modified as follow.
And I input “$(OPENCV_DIR)\include” in the “Additional Include Directories” entry,
and make the “Additional Dependencies” entry to include the next .lib file as the OpenCV Tutorials
Release 2.3 guides.
‘opencv_core231d.lib’
‘opencv__imgproc231d.lib’
‘opencv__highgui231d.lib’
‘opencv__ml231d.lib’
‘opencv__video231d.lib’
‘opencv__features2d231d.lib’
‘opencv__calib3d231d.lib’
‘opencv__objdetect231d.lib’
‘opencv__contrib231d.lib’
‘opencv__legacy231d.lib’
‘opencv__flann231d.lib’
And the include and library directories of visual c++ environment are modified as follow.
For library:
$(VSInstallDir)lib
$(VSInstallDir)
$(FrameworkSDKDir)lib
$(WindowsSdkDir)\lib
$(VCInstallDir)atlmfc\lib\i386
$(VCInstallDir)atlmfc\lib
$(VCInstallDir)lib
C:\opencv\build\x86\vc10\lib // modified
C:\opencv\build\x86\vc9\lib // modified
C:\opencv\build\x64\vc10\lib // modified
C:\opencv\build\x64\vc9\lib // modified
C:\opencv\build\gpu\x86\lib // modified
C:\opencv\build\gpu\x64\lib // modified
For include:
$(VCInstallDir)atlmfc\include
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include
$(VCInstallDir)include
C:\OpenCV\build\include\opencv // modified
C:\OpenCV\build\include\opencv2 // modified
C:\opencv\build\include // modified
It's seems that your processor can't recognize the user vairble OPEN_CV
first, make sure that the system\user vairble is correct.
in order to do that go to system properties --> on advance menu --> to go Enviroment variables --> make sure your system variable is correct , if not please create one with the path to your open cv library location.
it's seems like you are doing everything right ,
I believe your problem is that you have missed some at the post build step ...
Second , you'll have to copy the dll files from the openCV library to the location of your project.
in order to do so , please include an appropriate path on the post build step on your project.
go to your project : properties ... watch the picture
and include the command:
copy "C:\OpenCV2.31\CMake_Build\bin\Debug\*.dll"
copy "C:\OpenCV2.31\CMake_Build\bin\Debug\*.pdb"
Good luck
S
Basically it seems, that the compiler cannot find the OpenCV libraries or has trouble identifying the right one.
Make sure, that the needed libraries (i.e. opencv__xxx.lib) can be found in the directories you specified in the library directories (C:\opencv\build\x86\vc10\lib etc.) Also, you should only specify the directories for your platform, i.e. only vc9 (since you're using VS2008) and x86/x64 depending on your architecture.
The PRJ0018 warning indicates, that the OPENCV_DIR environment variable is not set. You can do this in the System properties dialog (usually you get it by right-clicking on "My Computer" and select "Properties", in Win7/Vista you have to go to "Extended System settings") on the "Extended" Tab, there's a Button "Environment variables". But if you already modified the include directories, you can omit the "Additional include directories" setting anyway.
may be it can help you.
Using OpenCV 2.1 with MS Visual Studio
OpenCV 2.1.0 with Visual Studio 2008