Question

I realise this i mighty popular question, but all of the other posts seem to follow the same idea. That the include, lib and bin folder need to be correctly configured. I believe my settings are correct, but i am still getting the LNK2019 error. What am i doing wrong?

Using Visual Studio 2012

I am getting the infamous LNK2019 error. Many posts of this issue seem to think it is a linker issue. I am using a library with lib and dll files. The project folder has an include, bin and lib folder that need to be configured in the project.

Install instructions are here..... http://opensource.mlba-team.de/xdispatch/docs/current/tutorial.html

However, this is clearly a linker issue as it occurs in other libraries of a similar type. I have followed the instructions for other posts and i'm still a bit lost. I believe this should be correct, but i have tried virtually every possible combination. Don't get it.

My Project Configurations

C++ -> General -> Additional Include Directories. C:\Users\Daniel\Documents\Visual Studio 2012\Projects\LibDispatchTest\xdispatch_0.7.2_Visual Studio 10_i386\include;%(AdditionalIncludeDirectories)

Linker -> General -> Additional Library Directories C:\Users\Daniel\Documents\Visual Studio 2012\Projects\LibDispatchTest\xdispatch_0.7.2_Visual Studio 10_i386\lib;%(AdditionalLibraryDirectories)

Linker -> Input -> Additional Dependancies: .....uuid.lib;odbc32.lib;odbccp32.lib;xdispatch.lib;%(AdditionalDependencies)

Environment Variables.

I have the PATH variable set.

C:\Chocolatey\bin;C:\Users\Daniel\Documents\Visual Studio 2012\Projects\VisionBase\xdispatch_0.7.2_Visual Studio 10_i386\bin;

The error messages are:

error LNK2019: unresolved external symbol "_declspec(dllimport) public: void __thiscall xdispatch::queue::async(class std::function<void __cdecl(void)> const &)" (__imp?async@queue@xdispatch@@QAEXABV?$function@$$A6AXXZ@std@@@Z) referenced in function "void __cdecl some_function(void)" (?some_function@@YAXXZ)   c:\Users\Daniel\documents\visual studio 2012\Projects\LibDispatchTest\LibDispatchTest\main.obj  LibDispatchTest 

error LNK1120: 1 unresolved externals   c:\users\daniel\documents\visual studio 2012\Projects\LibDispatchTest\Debug\LibDispatchTest.exe 1   1   LibDispatchTest

Seriously, am totally lost and i do not see what i am doing wrong here.

EDIT 1

This is similar to a sample from the above link, but modified to just couNT 1000000^2 and print some stuff. We just want to be able to compile and run this sample and i can correct my larger project exhibiting this issue. This project was made fresh with the simplest code that is representative of what i need to get working. Both this sample and my other project have this problem and produce the same error.

#include <xdispatch/dispatch>
#include <vector>
#include <cmath>

class SomeData {    
public:      
std::vector<double> a;   
std::vector<double> b;   
std::vector<double> c;   
std::vector<double> results;  
};

void do_calculations(SomeData* sd){

       // our output will go in here
       sd->results = std::vector<double>(sd->a.size());

       // the calculation - running on one thread only
       for(unsigned int i = 0; i < 1000000; i++){
              sd->results[i] = 0;
              for(unsigned int j = 0; j < 10000000; j++){
                     for(unsigned int z = 0; z < sd->c.size(); z++){
                            std::cout << i << " " << j << std::endl;
                     }
              }
       } }

/*  This function is getting called  from your main thread also powering  the user interface  */ 

void some_function() {
           SomeData* sd = new SomeData();       
           xdispatch::global_queue().async(${

                  // execute the heavy code
                  do_calculations(sd);
           }); } 

int main() {    
some_function();
    return 0; }

Is anyone able to help?

Was it helpful?

Solution

The binaries you used where built with and for MS Visual Studio 2010. Since then the CRT has changed quite a bit and might not be compatible, especially when parts of the STL is used. Because of that I do not recommend to ever use a C++ dll built with VS 2010 for use in VS 2012 or later. It could be that building and linking succeeds but during runtime you experience weird and unexpected issues. In your case even linking won’t work because std::function has changed its signature in the meantime, so lucky enough you already discover those incompatibilities at compile time.

I assume xdispatch will work just fine with VS2012 and maybe even VS2013, however you will need to do your own build for that. All information needed is summarized at [1]. A tarball containing the sources can always be found at [2].

[1] http://opensource.mlba-team.de/xdispatch/docs/current/requirements.html
[2] http://opensource.mlba-team.de/xdispatch/files/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top