Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;DLL未生成库,但正在查找库。错误LNK1104_C++_Dll_Visual Studio 2013_Dllexport - Fatal编程技术网

C++ C++;DLL未生成库,但正在查找库。错误LNK1104

C++ C++;DLL未生成库,但正在查找库。错误LNK1104,c++,dll,visual-studio-2013,dllexport,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

我现在正在做一个小项目,它将使用两个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;
    }
}
//MathFunctionsDLL.h
#ifdef mathfuncsdl_导出
#定义MathFuncsdl\u API\u declspec(dllimport)
#否则
#定义MATHFUNCSDLL\u API\uuu declspec(dllexport)
#恩迪夫
名称空间MathFuncs{
类MyMathFunctions{
公众:
//返回主管工资总额
静态MathFuncsdl_API双加(双a、双b、双c);
//返回工资总额
静态MathFuncsdl_API双加(双a、双b、双c、双d、双e、双f);
//返回合同总工资
静态MathFuncsdl_API双加(双a、双b、双c、双d、双e);
};
}
//MathFunctionsDLL.cpp
#包括
#包括“MathFunctionsDLL.h”
使用名称空间std;
名称空间MathFuncs{
double MyMathFunctions::add(双a、双b、双c){
返回a+b+c;
}
double MyMathFunctions::add(双a、双b、双c、双d、双e、双f){
返回a+b+c+d+e+f;
}
double MyMathFunctions::add(双a、双b、双c、双d、双e){
返回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;
        }
}
//Classes.h
#ifdef类DLL_导出
#定义类DLL\U API\U declspec(dllexport)
#否则
#定义类DLL\u API\u declspec(dllimport)
#恩迪夫
#包括
使用名称空间std;
命名空间类{
阶级雇员阶级{
字符串f_首字母;
字符串s_名称;
公众:
void set_name(字符串fInitial、字符串sName);
字符串get_f_initial();
字符串get_s_name();
};
班级主管班级:公共雇员班级{
双薪;
公众:
无效设定工资(双倍sal);
双薪;
};
类别工资类别:公共雇员类别{
双薪;
公众:
作废设定工资(双倍工资);
双薪;
};
类别合同类别:公共雇员类别{
双钟头;
工作两小时;
公众:
空套时间(双倍费率);
空套工作小时数(双重工作);
双get_hourlyRate();
双倍工作时间();
};
}
//类.cpp
#包括
#包括“Classes.h”
使用名称空间std;
命名空间类{
void employeeClass::set_name(字符串fInitial,字符串sName){
f_initial=fInitial;
s_name=sName;
}
字符串employeeClass::get_f_initial(){
返回f_首字母;
}
字符串employeeClass::get_s_name(){
返回s_名称;
}
无效主管类::设置工资(双薪){
薪金=sal;
}
双重主管类::获取工资(){
返回工资;
}
无效工资类别::设置工资(双倍){
薪金=sal;
}
双薪类::get_salary(){
返回工资;
}
void contractedClass::set_hourlyRate(双倍费率){
hourlyRate=速率;
}
void contractedClass::设置工时(双工时){
工作时间=工作时间;
}
双合同类::get_hourlyRate(){
返回时长;
}
double contractedClass::get_hoursWorked(){
返回工作小时数;
}
}

如果能提供任何帮助,解释为什么没有生成该库,我将不胜感激。作为旁注,这是我第一次处理类库,我对模块定义文件不太熟悉。再次感谢。

您似乎没有在任何函数声明中使用CLASSESDLL_API,这与在其他头文件中使用MATHFUNCSDLL_API不同。另外,您还没有在cpp中定义CLASSESDLL_导出来启用导出。非常感谢。这么简单的错误。再次感谢你。如果你的回答是一个评论,你介意接受吗?嗯。。。第二个DLL:您想导出整个类还是只导出函数?最好是导出整个类