每次我要使用外部资源时,我都会得到:collect2。exe:错误 ld 返回 1 退出状态
Everytime I'm going to use external sources I get: collect2. exe: error ld returned 1 exit status
例如,这段代码,我在代码块中创建一个新项目,添加这些文件,启用头文件,当尝试运行它时,我得到:
-------------- 构建:调试日期(编译器:GNU GCC 编译器(---------------
mingw32-g++.exe -Wall -fexceptions -g -std=c++11 -I..\date -c "C:\Users\kairenne\Documents\programming\Chapter 8\monster_generation\date\main.cpp" -o obj\Debug\main.o mingw32-g++.exe -o bin\Debug\date.exe obj\Debug\Date.o Date.h.gch obj\Debug\main.o Date.h.gch:文件无法识别:文件格式无法识别 识别的 collect2.exe:错误:ld 返回 1 退出状态 进程 终止状态 1(0 分钟、1 秒( 1 错误、0 警告(0 分钟、1 秒(
日期.h
#define DATE_H
class Date
{
private:
int m_year;
int m_month;
int m_day;
public:
Date(int year, int month, int day);
void SetDate(int year, int month, int day);
int getYear() { return m_year; }
int getMonth() { return m_month; }
int getDay() { return m_day; }
};
#endif
日期.cpp
// Date constructor
Date::Date(int year, int month, int day)
{
SetDate(year, month, day);
}
// Date member function
void Date::SetDate(int year, int month, int day)
{
m_month = month;
m_day = day;
m_year = year;
}
主.cpp
#include "Date.h"
using namespace std;
int main()
{
Date test(2000, 05, 10);
return 0;
}
永远不要编译或链接头文件。 因此,从链接器的命令中删除该Data.h.gch
,您将没事的。
如果在 IDE 中自动为您完成,请禁用"预编译标头"选项。
相关文章:
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 终端不会为C++文件创建.exe文件吗
- 在Windows中以.exe的形式运行c++
- Visual Studio mkl_link_tool.exe链接错误
- PrintWindow函数在notepad.exe中出错
- VSCode C++ 编译的exe感染了Win32:TrojanX-gen[Trj]
- 将返回值从 exe 传递到 bat,并将其传递给 C# 中的进程
- 获取当前正在运行的 exe 名称(不是路径)
- C++ 中的编译错误:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 从 exe 文件 (Visual Studio ) 启动时调试断言失败
- 1d.exe找不到SFML文件?
- VI工作室代码错误无法打开输出文件主.exe
- 找不到 -llibmysqld Collect2.exe:错误:ld 返回 1 退出状态
- 每次我要使用外部资源时,我都会得到:collect2。exe:错误 ld 返回 1 退出状态
- 对"displayForStudent(int, int const*, double const*, int)"的未定义引用 collect2.exe:错误:ld 返回 1 个退出状态
- mingw32/bin/ld.exe:找不到 -lfl collect2.exe:错误:ld 返回 1 个退出状态
- 生成文件gtkmm;collect2.exe:错误:ld返回1退出状态
- collect2.exe:错误:ld在编译带有gradle 2.3的C++代码时返回1退出状态
- 无法在Windows 10 collect2.exe上使用Python27 MingGW安装leven软件包错误
- collect2.exe[错误]ld返回1退出状态