Doubt in including libraries in VS08

Hi all,

I'm with a little doubt concerning linking libraries, I'm using Visual Studio 2008.

I've implemented a library in a project A: an 'example.h' and an 'example.cpp' file. In the .h file I provide the interface and in the .cpp I actually implement them.

Then I have another project B and want to use the library from the project A wihtout copying the hole code into this project B. So I use "include" with the full path to the header file in project A. But then it won't compile since it will not find the implementation of this interface.

The error I get is:
error LNK2028: unresolved token

It's cleary a wrong way to link things together. Can anyone help me to do it right?
Thanks in advance,
You should put all your includes in one place, then add that directory to the list of include directories (tools->options->projects and solutions->VC++ directories->show directories for: include files).
To fix the linker errors, you need to add the .cpp to the project.
closed account (z05DSL3A)
From the MSDN docs[1], it looks like you are trying to import native code into a pure managed (.net) project.

[1] http://msdn.microsoft.com/en-us/library/ms235590(VS.80).aspx
Hi,
@helios: Thanks, I think I did the same thing you described, but only for the current project. I went to: Project Properties > Configuration Properties > C/C++ > General > Additional Include Directories.

@Gray Wolf: I'm using only native code.

But I don't know exactly why, I only managed to compile everything putting all the code in header files. I only use .cpp code when using the main() procedure.
closed account (z05DSL3A)
Can you post the full output message or the bulid log (better)?
Here is the output error when I try to compile splitting into header and source files.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
	

Compiling...
Facility_Location.cpp
c:\documents and settings\guilherme\meus documentos\visual studio 2008\projects\facility_location\facility_location\Facility_Location_Algorithm1.h(95) : warning C4018: '<' : signed/unsigned mismatch
c:\documents and settings\guilherme\meus documentos\visual studio 2008\projects\facility_location\facility_location\Facility_Location_Gen.h(40) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
c:\documents and settings\guilherme\meus documentos\visual studio 2008\projects\facility_location\facility_location\Facility_Location_Gen.h(69) : warning C4018: '<' : signed/unsigned mismatch
.\Facility_Location.cpp(38) : warning C4018: '<' : signed/unsigned mismatch
.\Facility_Location.cpp(43) : warning C4018: '<' : signed/unsigned mismatch
Linking...
Facility_Location.obj : error LNK2028: unresolved token (0A0003E4) "public: void __thiscall Simplex::optimal_solution(class std::vector > &,class std::vector > &)" (?optimal_solution@Simplex@@$$FQAEXAAV?$vector@HV?$allocator@H@std@@@std@@AAV?$vector@NV?$allocator@N@std@@@3@@Z) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2028: unresolved token (0A0003E5) "public: double __thiscall Simplex::optimal_value(void)" (?optimal_value@Simplex@@$$FQAENXZ) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2028: unresolved token (0A0003E7) "public: int __thiscall Simplex::solve(void)" (?solve@Simplex@@$$FQAEHXZ) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2028: unresolved token (0A0003E8) "public: bool __thiscall Simplex::add_restriction(class std::vector > &,double,char)" (?add_restriction@Simplex@@$$FQAE_NAAV?$vector@NV?$allocator@N@std@@@std@@ND@Z) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2028: unresolved token (0A0003E9) "public: bool __thiscall Simplex::add_obj_func(class std::vector >)" (?add_obj_func@Simplex@@$$FQAE_NV?$vector@NV?$allocator@N@std@@@std@@@Z) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2028: unresolved token (0A0003EA) "public: __thiscall Simplex::Simplex(void)" (??0Simplex@@$$FQAE@XZ) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2019: unresolved external symbol "public: void __thiscall Simplex::optimal_solution(class std::vector > &,class std::vector > &)" (?optimal_solution@Simplex@@$$FQAEXAAV?$vector@HV?$allocator@H@std@@@std@@AAV?$vector@NV?$allocator@N@std@@@3@@Z) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2019: unresolved external symbol "public: double __thiscall Simplex::optimal_value(void)" (?optimal_value@Simplex@@$$FQAENXZ) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2019: unresolved external symbol "public: int __thiscall Simplex::solve(void)" (?solve@Simplex@@$$FQAEHXZ) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Simplex::add_restriction(class std::vector > &,double,char)" (?add_restriction@Simplex@@$$FQAE_NAAV?$vector@NV?$allocator@N@std@@@std@@ND@Z) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Simplex::add_obj_func(class std::vector >)" (?add_obj_func@Simplex@@$$FQAE_NV?$vector@NV?$allocator@N@std@@@std@@@Z) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
Facility_Location.obj : error LNK2019: unresolved external symbol "public: __thiscall Simplex::Simplex(void)" (??0Simplex@@$$FQAE@XZ) referenced in function "double __cdecl solve1(class std::vector >,class Matrix)" (?solve1@@$$FYANV?$vector@NV?$allocator@N@std@@@std@@V?$Matrix@N@@@Z)
C:\Documents and Settings\Guilherme\Meus documentos\Visual Studio 2008\Projects\Facility_Location\Debug\Facility_Location.exe : fatal error LNK1120: 12 unresolved externals
closed account (z05DSL3A)
I have been playing around with a few ideas, but have not been able to recreate an error LNK2028.

You may have to post your code, and give a description of what you have done, but is not happy about the Simplex class.

Topic archived. No new replies allowed.