C ++ DLL没有生成库,但正在寻找库。错误LNK1104

时间:2014-02-11 00:27:18

标签: c++ dll visual-studio-2013 dllexport

我正在开发一个小项目,它将使用两个DLL。其中一个工作正常,但我的另一个不是。我之前得到的是LNK2019但是通过添加参考文献解决了这个问题。我现在收到LNK1104错误:

Error   1   error LNK1104: cannot open file '...System\TechGeniusOutSourcePayRoll\Debug\Classes.lib'

显然,通过相关文件夹,没有'Classes.lib',但我有代码允许导出,类似于第一个DLL。下面是我工作的DLL的代码

//MathFunctionsDLL.h
#ifdef MATHFUNCSDLL_EXPORTS
#define MATHFUNCSDLL_API __declspec(dllimport) 
#else
#define MATHFUNCSDLL_API __declspec(dllexport) 
#endif

namespace MathFuncs {

    class MyMathFunctions {
public:
    //Return Supervisor Total Salaries
    static MATHFUNCSDLL_API double add(double a, double b, double c);

    //Return Salaried Total Salaries
    static MATHFUNCSDLL_API double add(double a, double b, double c, double d, double e, double f);

    //Return Contracted Total Wages
    static MATHFUNCSDLL_API double add(double a, double b, double c, double d, double e);
    };
}

//MathFunctionsDLL.cpp
#include <iostream>
#include "MathFunctionsDLL.h"

using namespace std;

namespace MathFuncs {
    double MyMathFunctions::add(double a, double b, double c) {
        return a + b + c;
    }

double MyMathFunctions::add(double a, double b, double c, double d, double e, double f) {
    return a + b + c + d + e + f;
    }

double MyMathFunctions::add(double a, double b, double c, double d, double e) {
    return a + b + c + d + e;
    }
}

以上所有这些都很好。下面是我的第二个DLL的代码。

//Classes.h
#ifdef CLASSESDLL_EXPORTS
#define CLASSESDLL_API __declspec(dllexport)
#else
#define CLASSESDLL_API __declspec(dllimport)
#endif

#include <string>
using namespace std;

namespace Classes {

class employeeClass {
    string f_initial;
    string s_name;
public:
    void set_name(string fInitial, string sName);
    string get_f_initial();
    string get_s_name();
    };

class supervisorClass : public employeeClass{
    double salary;
public:
    void set_salary(double sal);
    double get_salary();
    };

class salariedClass : public employeeClass{
    double salary;
public:
    void set_salary(double salary);
    double get_salary();
    };

class contractedClass : public employeeClass{
    double hourlyRate;
    double hoursWorked;
public:
    void set_hourlyRate(double rate);
    void set_hoursWorked(double worked);
    double get_hourlyRate();
    double get_hoursWorked();
    };
}

//Classes.cpp
#include <iostream>
#include "Classes.h"

using namespace std;

namespace Classes {

void employeeClass::set_name(string fInitial, string sName) {
    f_initial = fInitial;
    s_name = sName;
    }

string employeeClass::get_f_initial() {
    return f_initial;
    }

string employeeClass::get_s_name() {
    return s_name;
    }

void supervisorClass::set_salary(double sal) {
    salary = sal;
    }

double supervisorClass::get_salary() {
    return salary;
    }

void salariedClass::set_salary(double sal) {
    salary = sal;
    }

double salariedClass::get_salary() {
    return salary;
    }

void contractedClass::set_hourlyRate(double rate) {
    hourlyRate = rate;
    }

void contractedClass::set_hoursWorked(double worked) {
    hoursWorked = worked;
    }

double contractedClass::get_hourlyRate() {
    return hourlyRate;
    }

double contractedClass::get_hoursWorked() {
    return hoursWorked;
        }
}

对于为什么不生成库而提供的任何帮助,我将不胜感激。作为旁注,这是我第一次处理类库,我对模块定义文件不太满意。再次感谢你。

0 个答案:

没有答案