I'm trying to compile a c++ source code file from the DXC competition.
The instructions are:
To compile any of the C++ examples (or a DA written in C++) under Windows, MS
Visual C++ 8.0 (2005) is required. Make sure to add %DXC_HOME%\Lib and
%DXC_HOME%\Include to your library and header search paths respectively, and add
dxcApi.lib to your list of libraries (or dxcApid.lib if compiling in debug
mode).
I added Lib and the Include libraries to the library and search paths and it imported them. What I didn't understand is the meaning of the second step: "add dxcApi.lib to your list of libraries" - what does it mean?
Without this step I'm getting linker errors, such as:
Error 1 error LNK2019: unresolved external symbol
"__declspec(dllimport) public: _thiscall
Dxc::CandidateSet::~CandidateSet(void)"
(_imp_??1CandidateSet#Dxc##QAE#XZ) referenced in function "public:
void __thiscall ExampleDA::sendDiagnosis(void)"
(?sendDiagnosis#ExampleDA##QAEXXZ) D:\Dropbox\Work\Visual Studio
2010\Projects\DXC11\DXC11\ExampleDA.obj DXC11
I'm stuck with this problem for quite some time now and I'm desperate for help!
Thanks a lot
You need to add the specific lib file to the libraries list, so that the linker can search it for the symbols you're missing.
The task says to add that particular .lib to the list of libraries that get linked to your code. Without saying that this library should be linked, the implementation for the functions defined in its headers is not available to the linker and you get that unresolved external symbol.
In VS, you can add something to the linked libraries list either through a #pragma comment or in the project settings:
// at the top of main.cpp, preferrably
#pragma comment(lib, "the_lib_name.lib") // .lib optional
You can have different libraries for debug and release with simply surrounding the #pragma comment in an #if block:
#ifdef NDEBUG // release
#pragma comment(lib, "the_lib_name.lib")
#else // debug
#pragma comment(lib, "the_lib_named.lib") // most debug libraries end with a 'd'
#endif
And for the project settings you can do so with
[Project] -> <Project Name> Properties (or Alt-F7) -> Configuration Properties
-> Linker -> Input -> Additional Dependencies
Just add the_lib_name.lib at the front (followed by either a space or a semi-colon ;). Make sure you add the correct library for the active project configuration (debug / release).
Related
I'm currently attempting to compile a VST3 plugin (or any C++ code, for that matter) for the first time, mainly just following Steinberg's own tutorial for all things except the actual sound processing.
Attempting to compile throws an "unresolved external symbol" error:
Error LNK2019 unresolved external symbol "public: __cdecl VSTGUI::VST3Editor::VST3Editor(class Steinberg::Vst::EditController *,char const *,char const *)" (??0VST3Editor#VSTGUI##QEAA#PEAVEditController#Vst#Steinberg##PEBD1#Z) referenced in function "public: virtual class Steinberg::IPlugView * __cdecl Itisdud::Split_TimesController::createView(char const *)" (?createView#Split_TimesController#Itisdud##UEAAPEAVIPlugView#Steinberg##PEBD#Z) Split_Times D:\programme\VST3Dev\Split_times\Split_Times\build\split_timescontroller.obj 1
The function that causes this, createView, is still the default it is when created by the Project Generator:
IPlugView* PLUGIN_API Split_TimesController::createView (FIDString name)
{
// Here the Host wants to open your editor (if you have one)
if (FIDStringsEqual (name, Vst::ViewType::kEditor))
{
// create your editor here and return a IPlugView ptr of it
auto* view = new VSTGUI::VST3Editor (this, "view", "split_timeseditor.uidesc");
return view;
}
return nullptr;
}
Copying the createView function from the again and adelay samples didn't work either.
As the Project generator only includes vstgui4/vstgui/plugin-bindings/vst3editor.h and not the vst3editor.cpp file, I tried including that as well (As I've read that not having the actual implementation there might be the cause of the issue), however that didn't fix the issue but made a lot of other errors happen upon compiling.
I also tried to follow this, including the cpp files noted there and changing the createView function to what is written there, however this also only led to there being a bit more than 300 errors upon compiling.
Copying the includes from the again sample didn't work either.
What would I need to include for this to work?
Those are the linker errors as you didn't instruct the linker where to find the required library files whose functions you are using.
Remember that compilation is a 2-step process that involves compilation and linking so it is best to separate them.
Lets assume you are using Visual Studio on Windows, and lets assume your VST SDK is installed on
C:\VST3SDK.
The first thing you should do is fire-up Visual Studio and select File->Open->CMake and go locate the CMake.txt file here
C:\VST3SDK\VST3_SDK.
After this file is loaded you will find on Visual Studio Solution Explorer a list of ready-made projects that come with the VST SDK loaded.
You will find that one of these projects is called Libraries and that is THE first action you have to do.
Now you have to build the correct library depending on whether you want to make 32-bits or 64-bits VSTs and you should set the configuration of the Libraries project accordingly.
You will build these libraries and if you hadn't changes any setting the libraries will be found at
C:\VST3SDK\VST3_SDK\out\build\x64-Debug\lib
or
C:\VST3SDK\VST3_SDK\out\build\x64-Release\lib
the necessary libraries being:
base.lib
pluginterfaces.lib
sdk.lib
sdk_common.lib
sdk_hosting.lib
vstgui.lib
vstgui_standalone.lib
vstgui.support.lib
vstgui_uidescription.lib
The above step ensures that you now have the necessary library files your VSTs will depend on.
Now assuming you have a VST sample project, lets say that you got from Git-hub and that it were written and setup correctly to run on Visual Studio, i.e. it came with a
myVST.vcxproj file.
Then you could paste the following pragmas on a prominent VST file such as the factory.cpp
#pragma comment(lib, "base.lib")
#pragma comment(lib, "pluginterfaces.lib")
#pragma comment(lib, "sdk.lib")
#pragma comment(lib, "sdk_common.lib")
#pragma comment(lib, "sdk_hosting.lib")
#pragma comment(lib, "vstgui.lib")
#pragma comment(lib, "vstgui_standalone.lib")
#pragma comment(lib, "vstgui_support.lib")
#pragma comment(lib,
"vstgui_uidescription.lib")
(Had to abbreviate due to confusing formatting requirements of this site but replace like "vstgui.lib" with a fully qualified path like
"C:/VST3SDK/VST3_SDK/out/build/x64-Debug/lib/vstgui.lib"
Now if your project properties
C/C++ _> General _> Additional Include Directories has correct entries that will tell the compiler the paths it will find ALL the #include files, then you will find that if you right click on any compilable file (c, cpp, rc ...) and select Compile then the file should successfully compile into an object file without any Compiler errors otherwise it is an indication that the compiler cannot find the required header
files.
But the problem you face are the linker problems, the linker can not find the required libraries of functions you have used in your project and the solution is just pasting the pragmas above.
Iam trying to write a console application in 64 bit.I have linked the required library in the
Properties->Linker->Addidional Input->fltLib.lib
It wouldnt work so I added Addidional Directory in
Propertied->Linker->General->Addidtional Directory->C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x64
It still gives unresolved symbol FilterConnectCommunicationPort
I also tried copying the fltlib.lib file in my local directory and then
#pragma comment(lib, "fltLib.lib")
Still it complains about unresolved external externals.
After that I tried adding header directory in
C/C++->General->Additional Include Directory->C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um
Still it gives errors saying unresolved external symbols.
I have also tried including the headers in an extern "C" block.
I'm really confused as to what I'm doing wrong.
In Visual Studio you have to add the folder, which you have already done by setting the property Linker > General > Additional Library Directories. You also need to set the name of the file you will be linking against. This is done by putting the "fltlib.lib" in the Linker > Input > Additional Dependencies field.
If you have multiple lib files in one directory it might be easier to use the Linker > Command Line option: [PATH TO LIB FOLDER]*.lib". Keep in mind that statically linking (against lib files) increases the size of your build files, so unnecessary linking against everything should be avoided
Good Afternoon, so I have a question about including the aux_klib library in my Kernel Mode Driver, for some reason I get the same error for all aux_klib functions.
Error 1 error LNK2019: unresolved external symbol AuxKlibInitialize referenced in function "unsigned char __cdecl Main(struct MainInfo*)" (?MainInfo##YAEPEAU__MainInfo###Z)
I did #pragma comment(lib, "aux_klib.lib") in my project and no luck, also the driver is coded in cpp. I also added the lib to my project and made sure it was x64 as that is the projects build architecture. I also tried including the function via extern "C" with out the header and just the lib but no luck, I also added all the library paths to the linker settings and what not. Any ideas are welcome!
Properties->Linker->Input->Additional Dependencies add "AUX_KLIB.LIB"
This worked for me
I had the same problem with linking Aux_klib.lib, so I set /VERBOSE:Lib.
Right click on the project -> Properties -> Linker -> General -> Show
Progress
As I understand it, For Libraries Searched /VERBOSE:Lib shows the libraries search and I've noticed that Aux_klib.lib is not in that search.
And I noticed another thing in the output, /NODEFAULTLIB is passed in the command line as well.
As #RbMm says,
are he search for aux_klib.lib may be you used /nodefaultlib option.
in this case #pragma comment(lib, "aux_klib.lib") will be have no
effect.
So I changed Ignore All Default Libraries
Right click on the project -> Properties -> Linker -> Input -> Ignore
All Default Libraries
to No and everything linked and compiled perfectly.
TL;DR
In short, try to change Ignore All Default Libraries under Linker to No and use #pragma comment(lib, "aux_klib.lib").
I am using Octave within MSVC 2010. First I downloaded Octave latest version at this link. After installing, I tried to run this simple code:
#include <iostream>
#include<octave-3.6.4\octave\oct.h>
#include<octave-3.6.4\octave\config.h>
#include<octave-3.6.4\octave\octave.h>
using namespace std;
int main (void)
{
std::cout << "Hello Octave world!\n";
system("PAUSE");
return 0;
}
Note that I added these links to my project as well:
C:\Software\Octave-3.6.4\include\octave-3.6.4\octave--->Includ. Dir.,
C:\Software\Octave-3.6.4\include--->Includ. Dir.
C:\Software\Octave-3.6.4\lib--->Lib. Dir.
C:\Software\Octave-3.6.4\lib\octave\3.6.4--->Lib Dir.
I also added 1 and 2 to Additional Inc Dir!!
C:\Software\Octave-3.6.4\lib\octave\3.6.4--->Additional Lib. Dir in Linker.
First, I got this error that it cannot find math.h in Program Files while this file was in my Program Files (x86). So, I changed it to: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h and it solved this error. However, now I get this error:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall octave_value::~octave_value(void)" (__imp_??1octave_value##QAE#XZ) referenced in function "public: void * __thiscall octave_value::`vector deleting destructor'(unsigned int)" (??_Eoctave_value##QAEPAXI#Z)
It is not sufficient to add the library path to the project.
You have to add the library name(s) (including .lib) to the "Additional Dependencies" in the Linker/Input tab.
Edit
To verify what library has been searched you can enable the Linker/General/Show Progress option. Then you can see in the Build Output what library has actually be used in symbol search.
Edit
Your example code doesn't show any instance of an array of octave_value instances. So it's a bit surprising that you need to link with any library with the code you've shown. But anyway you want to have these externals resolved.
If there is no other resource (manual, ...) you should detect where the octave_value class is implemented. This can be a static library or a DLL.
You can detect the DLL implementation with a dumpbin /exports on the DLLs. In that case you need the corresponding import libraries. The LIB should have the same base name as the DLL. Verify that you have added that dependency and how the linker searches this library for symbols.
The name of the symbols __imp_??1octave_value##QAE#XZ indicates that it should be in a DLL. But since you have a problem you might want to search LIBs too.
You can detect the LIB implementation with a dumpbin /symbols. In that case you have to add the LIB directly. Again verify it with the Build Output.
The dumpbin output will probably very verbose. You should use either findstr to limit the output or redirect the output to a file and search the symbols with an editor of your choice.
Search for ocatave_value. If you find a different decoration of the constructor and destructor you might have missed to set an option. A preprocessore directory could be used to define how the library is use. E.g. if you find octave_value::octave_value without the __imp_ prefix you have accidentily compiled for a DLL version altough the class is implemented in a static library. In that case, read the manual and ask at the octave mailing list forum or whatever.
I am trying to statically link this library into my VS C++ project.First I compiled the source as a static lib.Linked it via VS Project properties.The .exe project works fine.Then I read this MS manual on how to compile the static lib into the executable and following the steps outlined there now if I am running the executable I am getting these errors:
Error 3 error LNK2019: unresolved external symbol __imp__glBlendFunc#8
referenced in function _text_buffer_render E:\Documents\visual studio
2012\Projects\XXXXEngine\FreeTypeTest\text-buffer.obj
Error 4 error LNK2019: unresolved external symbol __imp__glBindTexture#8
referenced in function _text_buffer_render E:\Documents\visual studio
2012\Projects\XXXXEngine\FreeTypeTest\text-buffer.obj
To me it seems like GLEW.lib errors.Does it mean I have to link also glew.lib statically as the freetype GL depends on it ?
Also, can I just use the lib with the executable without adding it to references, or it won't work in release build?I am asking it as I am quite confused with how the static linking should be done.I mean,now the executable works without adding the library to the project reference.Then why can't it be used just like this?
To me it seems like GLEW.lib errors
They are not, glBindTexture() is an OpenGL function. The MSDN library page is here. Scroll to the bottom, it shows you the .h file that declares it (you already that right since the compiler didn't complain) and the .lib you need to link.
Right-click your project, Properties, Linker, Input, Additional Dependencies setting. Add opengl32.lib. Or to use the upvoted answer's suggestion, you can inject the linker directive in your source code:
#include <gl\gl.h>
#pragma comment(lib, "opengl32.lib")
Have you tried to pragma mark your library?
Like so:
#pragma comment(lib, "any.lib");