概述
LINK : fatal error LNK1104
vs2010和Matlab R2013a 混合编程
..libMyAdd.lib 到底是从哪里出来的
在vs2010里面,怎么看?
我在附加依赖项里面加的不是..libMyAdd.lib ..是?斜杠前面是文件名or路径名?
#include
#include
#include
#include "mclmcr.h"
#include "matrix.h"
#include "mclcppclass.h"
#include "libMyAdd.h"
using namespace std;
int main()
{
double a = 6;
double b = 9;
double c;
if( !libMyAddInitialize())
{
std::cout <
return -1;
}
mwArray mwA(1, 1, mxDOUBLE_CLASS);
mwArray mwB(1, 1, mxDOUBLE_CLASS);
mwArray mwC(1, 1, mxDOUBLE_CLASS);
mwA.SetData(&a, 1);
mwB.SetData(&b, 1);
MyAdd(1, mwC, mwA, mwB);
c = mwC.Get(1, 1);
std::cout<
libMyAddTerminate();
mclTerminateApplication();
return 0;
}
//
// MATLAB Compiler: 4.18.1 (R2013a)
// Date: Sat Dec 13 16:42:33 2014
// Arguments: "-B" "macro_default" "-W" "cpplib:libMyAdd" "-T" "link:lib"
// "MyAdd" "-d" "E:MATLABbintestC"
//
#pragma once
#ifndef __libMyAdd_h
#define __libMyAdd_h 1
#if defined(__cplusplus) && !defined(mclmcrrt_h) && defined(__linux__)
# pragma implementation "mclmcrrt.h"
#endif
#include "mclmcrrt.h"
#include "mclcppclass.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__SUNPRO_CC)
/* Solaris shared libraries use __global, rather than mapfiles
* to define the API exported from a shared library. __global is
* only necessary when building the library -- files including
* this header file to use the library do not need the __global
* declaration; hence the EXPORTING_ logic.
*/
#ifdef EXPORTING_libMyAdd
#define PUBLIC_libMyAdd_C_API __global
#else
#define PUBLIC_libMyAdd_C_API /* No import statement needed. */
#endif
#define LIB_libMyAdd_C_API PUBLIC_libMyAdd_C_API
#elif defined(_HPUX_SOURCE)
#ifdef EXPORTING_libMyAdd
#define PUBLIC_libMyAdd_C_API __declspec(dllexport)
#else
#define PUBLIC_libMyAdd_C_API __declspec(dllimport)
#endif
#define LIB_libMyAdd_C_API PUBLIC_libMyAdd_C_API
#else
#define LIB_libMyAdd_C_API
#endif
/* This symbol is defined in shared libraries. Define it here
* (to nothing) in case this isn't a shared library.
*/
#ifndef LIB_libMyAdd_C_API
#define LIB_libMyAdd_C_API /* No special import/export declaration */
#endif
extern LIB_libMyAdd_C_API
bool MW_CALL_CONV libMyAddInitializeWithHandlers(
mclOutputHandlerFcn error_handler,
mclOutputHandlerFcn print_handler);
extern LIB_libMyAdd_C_API
bool MW_CALL_CONV libMyAddInitialize(void);
extern LIB_libMyAdd_C_API
void MW_CALL_CONV libMyAddTerminate(void);
extern LIB_libMyAdd_C_API
void MW_CALL_CONV libMyAddPrintStackTrace(void);
extern LIB_libMyAdd_C_API
bool MW_CALL_CONV mlxMyAdd(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
/* On Windows, use __declspec to control the exported API */
#if defined(_MSC_VER) || defined(__BORLANDC__)
#ifdef EXPORTING_libMyAdd
#define PUBLIC_libMyAdd_CPP_API __declspec(dllexport)
#else
#define PUBLIC_libMyAdd_CPP_API __declspec(dllimport)
#endif
#define LIB_libMyAdd_CPP_API PUBLIC_libMyAdd_CPP_API
#else
#if !defined(LIB_libMyAdd_CPP_API)
#if defined(LIB_libMyAdd_C_API)
#define LIB_libMyAdd_CPP_API LIB_libMyAdd_C_API
#else
#define LIB_libMyAdd_CPP_API /* empty! */
#endif
#endif
#endif
extern LIB_libMyAdd_CPP_API void MW_CALL_CONV MyAdd(int nargout, mwArray& c, const mwArray& a, const mwArray& b);
#endif
#endif
------解决思路----------------------
1、
添加库(Libs)文件目录
项目->属性->配置属性->连接器->常规->附加库目录
2、
添加编译所需要(依赖)的 lib 文件
项目->属性->配置属性->连接器->输入->附加依赖项”里填写“xxx.lib”。 (等同于“#pragma comment(lib, "xxx.lib") ”语句)
我感觉需要先添加库目录,你的库目录没有添加所以连接器去debug目录的上一层找..libMyAdd.lib,因此没有找到。
你试试我上面的两步。看看行不
最后
以上就是热心心情为你收集整理的c语言link错误,LINK : fatal error LNK1104,该怎么解决的全部内容,希望文章能够帮你解决c语言link错误,LINK : fatal error LNK1104,该怎么解决所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复