In visual studio 2008, I have created a static dll called test_static.dll. I am trying to call this from one application. I have included this dll in source files folder and the header file related to it in headers folder. When i am running the application I am getting following liking error. Please give me a solution.
error LNK2019: unresolved external
symbol "struct morph_output * __cdecl
morpho_data(struct morph_input *)"
(?morpho_data##YAPAUmorph_output##PAUmorph_input###Z)
referenced in function _wmain
1>D:\test_app\Debug\test_app.exe :
fatal error LNK1120: 1 unresolved
externals 1>Build log was saved at
"file://d:\test_app\test_app\Debug\BuildLog.htm"
Here test_app is application that is using static dll. and morpho_data is the dll function which is taking input as structure and returning another structure.
When compiling the dll you need to create an import library - a .lib file (Linker->Advanced->Import Library) and include it into the list of libraries your .exe depends on (Linker->Input->Additional Dependencies and Linker->General->Additional Library Directories).
Did you add test_static.lib as input to the linker in the project settings?
Did you include the header file where the function is declared ?
Related
I'm new to CMake and also new to compiling mixed source, I have received the following errors while trying to compile using CMake and Visual Studio 14.0
(Link target) ->
main.obj : error LNK2001: unresolved external symbol ethash_get_cachesize
main.obj : error LNK2001: unresolved external symbol ethash_get_datasize
The layout of my project is like this:
I have ethash_get_cachesize and ethash_get_datasize defined in internal.c in a directory ethminer/libethash/ these are C source. im sure that the CMake file that came with this set of sources is ok as the project has compiled before without issue, it has only given me LINK problems after i have added the following:
I have another directory /ethminer/dag/ with a C++ source "dag.cpp" and "dag.h" these are both C++ files. and the CMake file.
set(SOURCES
DAG.h DAG.cpp
)
include_directories(BEFORE ..)
link_directories(BEFORE ..)
the C++ source file "dag.cpp" includes #include <libethash/internal.h>
however I fear that I am missing something to tell CMake or Visual Studio to find the files it needs from the directory containing "internal.c"
any help would be much appreciated
I am creating Visual Studio VC++ app project on Win 7, that utilizes the libsndfile library.
The library( libsndfile-1.dll,libsndfile-1.dll) is at :
C:\SVN\US\AdditionalIncludeDir\libsndfile
and its headers(sndfile.hh,sndfile.h) at
C:\SVN\US\AdditionalIncludeDir\Include
the Visual Studio Project is at :
C:\SVN\US\Simulation\audioSim.vcxproj
I have added the library header reference as:
Project properties->C/C++->General->Additional Include Directories->
..\AdditionalIncludeDir\Include
and static lib reference as
Project properties->Linker>Additional dependencies:
libsndfile-1.lib
Project properties->Linker>Additional Library
Dir:..\AdditionalIncludeDir\libsndfile
I also have added
..\AdditionalIncludeDir\libsndfile
to path in user environment variable in Win 7.
The toplevel C++ file uses the library as:
SndfileHandle mic1(".\\filedata\\mic1.wav");
where mic1.wav is at
C:\SVN\US\Simulation\filedata
Building the project still gives me error:
error LNK2019: unresolved external symbol _sf_open referenced in
function "public: __thiscall SndfileHandle::SndfileHandle(char const
*,int,int,int,int)" (??0SndfileHandle##QAE#PBDHHHH#Z)
Why would this happen?
Thanks
sedy
I also had this problem. I had set "Additional Include Directories" (C:\Program Files (x86)\Mega-Nerd\libsndfile\include) and "Additional Library Directories" (C:\Program Files %28x86%29\Mega-Nerd\libsndfile\lib) in the project settings.
This fixed the problem:
Go to project properties -> Configuration properties -> Linker -> Input and type in the lib file name libsndfile-1.lib in the "Additional Dependencies" field.
I am getting below error while migrating my project from VS2008 to VS2015.
21>TFCLd.lib(cryptlib.obj) : warning LNK4217: locally defined symbol _fprintf imported in function _OpenSSLDie
21>TFCLd.lib(rsa_sign.obj) : warning LNK4049: locally defined symbol _fprintf imported
21>TFCLd.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _OpenSSLDie
21>TFCLd.lib(rsa_sign.obj) : error LNK2001: unresolved external symbol __imp____iob_func
The project builds in VS2008 but with above error in VS2015. May I know what am I missing.
Put this in the begin of your class header file or in stdafx.h
FILE _iob[] = { *stdin, *stdout, *stderr };
extern "C" FILE * __cdecl __iob_func(void) { return _iob; }
Have a look at:
http://openssl.6102.n7.nabble.com/Compiling-OpenSSl-Project-with-Visual-Studio-2015-td59416.html
Changing line 310 of the file e_os.h in the openssl root directory from
# if _MSC_VER> =1300
to # if _MSC_VER> =1300 && _MSC_VER <= 1800
fixes the problem.
The original poster describes the cause of the problem:
In the Visual Studio 2015 the libraries with old names were redesigned
Visual Studio 2015 is referred to as _MSC_VER == 1900.
Be sure your libcurl.lib was compiled with the same IDE (MSVC 2015) as your application.
Your openSSL version is outdated for VS2015. Download and install latest stable version from https://www.openssl.org/source/
Edit: How to install it: https://www.youtube.com/watch?v=icNn-eJif9k
Generally speaking, click on the project in the Solution Explorer, and go-->Properties-->C/C++-->Code Generation-->Runtime Library. Make the libraries and binary all the same option.
I'm having trouble to compile VTK 5.10.1 example code in Visual Studio 2010 on Windows 7 64 bit SP1.
First of all, I installed VTK using this tutorial.
No errors occured while installing VTK and the example executables like cone.exe located at C:\VTK5.10.1_cmake\bin\Release are running just fine.
In Visual Studio 2010 I started a new Win32 console application and tested the first example code from this site.
I edited the projekt properties (additional include directories, additional Library directories and additional dependencies).
The linker errors looked like that:
vtktest.obj : error LNK2019: unresolved external symbol ""public: void __thiscall vtkRenderer::AddActor(class vtkProp *)" (?AddActor#vtkRenderer##QAEXPAVvtkProp###Z)" referenced in function "_main".
Most of the the other people with the same error forgot to add the libs to the additional dependencies.
However I added all libs in the C:\VTK5.10.1_bin\lib\vtk-5.10 directory and the opengl32 library. I tried to seperate the libs by a space, a semicolon and a new line.
Then, I read that people are using the shared libraries. I'm not really familiar with dlls. I reinstalled VTK
with shared libraries options turned on and copied the resulting dlls to the System32 directory.
Now, the errors looks slightly different:
vtktest.obj : error LNK2019: unresolved external symbol ""__declspec(dllimport) public: void __thiscall vtkRenderer::AddActor(class vtkProp *)" (__imp_?AddActor#vtkRenderer##QAEXPAVvtkProp###Z)" referenced in function "_main".
Any help would be appriciated!
Nevermind, forgot to change the platform to x64 :/
I have received a Visual C++ QT based project from our customer. I have installed QT libraries then I have compiled the project. The Project was compiled without any problems.
Now, I need to include a new additional GUI interface with the existing project. I have created a GUI in QT designer then saved in the source directory of VC++ project. Then I have written .h and .cpp file for new GUI and could call this interface. Now I need to include SIGNALS and SLOTS, when I include Q_OBJECT in .h file. I have compilation error.
These are the errors, please help me to solve this problem:
unresolved external symbol "public: virtual struct QMetaObject const * __thiscall BetaLineServer::metaObject(void)const " (?metaObject)
unresolved external symbol "public: virtual void * __thiscall BetaLineServer::qt_metacast(char const *)"
unresolved external symbol "public: virtual int __thiscall BetaLineServer::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#
Any time you add a Q_OBJECT macro to a class you need to be sure to rerun qmake and then compile.
All you need is to compile the header files with moc that contain Q_OBJECT macro. And how to do that? here it is
You can manually type commands for compiling moc or uic files OR
-> Install Qt-VS addin. http://qt.nokia.com/downloads/visual-studio-add-in
-> Now, open visual studio and create a new Qt project as described in here and then
-> Right click on a header file that contains the Q_OBJECT macro you should find something like below. Copy these commands into your project.
-> Replace the header file name with yours in the 'Command Line' command
-> compile once and that should generate moc_xxxxx.cpp files, include them in your project.
For future reference, if you create a Qt project in VS using this plugin you should have these commands automatically added
You probably just need to add your .ui, .cpp and .h files to the project file.
Qt will run 'moc' on the ui file if it's listed there, which creates source code to supply your missing symbols.
Exclude .h file from the project and include it again - moc_.cpp will appear in the "Generated Files", and linking errors are disapeared.