Problems with dll's and lib's

Hey, I've made a dll (and lib) for an additional maths library and it appears to export perfectly fine but when I try and import it into other projects I get this message "error: LNK1104 cannot open file 'filename.lib'"... This is my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <cmath>

//#define DLLEXPORT
#pragma region DLL_SET
#ifdef DLLEXPORT
#define DLL __declspec(dllexport)
#else
#define DLL __declspec(dllimport)
#endif
#pragma endregion

#ifndef PI
#define PI 3.141591653589793
#endif
#define DEG_PER_RAD 57.29577951308232
#define RAD_PER_DEG 0.017353292519943

static class DLL ExMaths{
public:
	template<typename T> T* orderSL(int number, T var[]);
	template<typename T> T* orderLS(int number, T var[]);
	template<typename T> T* orderReverse(int number, T var[]);
	template<typename T> void swap(T& var1, T& var2);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	double toDegrees(double radians);		//Returns degree conversion of given radians
	double toRadians(double degrees);		//Returns radian conversion of given degrees
	double toBearing(double degrees);		//Returns clockwise rotation in degree from Y+
	double fromBearing(double degrees);	//Returns elevation rotation in degree from X+
	double rectifyAngle(double degrees, bool ABS = false);	//Limits the degrees of an angle to (-180|180)false, (0|360)true
	
	double polR(double x, double y);				//Returns the length from (0, 0) to (x, y)
	double polT(double x, double y);				//Returns the angle of elevation from (0, 0) to (x, y)
	double recX(double radius, double theta);		//Returns the X coordinate from a polar point of (radius, angle of elevation)
	double recY(double radius, double theta);		//Returns the Y coordinate from a polar point of (radius, angle of elevation)
	double pythag(int num, double roots[]);		//Calculates pythagorous theorum for array of lengths given
	double average(int num, double sums[]);		//Calculates the mean average for array of numbers given
}Maths;

#ifndef DLLEXPORT
#pragma comment(lib, "Debug/Maths.lib")
#endif
#undef DLL 


Someone's told me that VS will not import files if there are missing export functions, and I've used a program called "Dependency Walker" and found out that none of the template functions are present in the dll so I think it's this that may be my problem...
How do I fix this?
Well, first of all, your error doesn't show the problem with exporting dll. The linker just cannot find the file. You should either provide full path to lib in
Linker->Input->Additional Dependencies
or add the directory where the lib is located to
Linker->General->Additional Library Directories
.

Second, why do you make a class with a static instance? Namespace would work better in this case.

Third, with template functions you should either provide their body in the header file (as the templates are instantiated upon use), or use explicit template instantiation - read more here: http://msdn.microsoft.com/en-us/library/7k8twfx7.aspx
Well the static class was because originally this inherited from something but as you can see there is no longer any inheritance so a namespace would be better, when including the library I do know it's in the correct place and I've done something similar like this so I know it works.
But I didn't know that about templates, but I don't think that'd have anything to do with opening the library will it?
Last edited on
Well i'll eat my words... The FULL path works fine, if I added the directory of the folder I have full of my DLLs I'd need to link through all sub directories won't I?
Topic archived. No new replies allowed.