我正在为树莓派(ARM)交叉编译(主机: x86 linux),使用
arm-bcm2708hardfp-linux-gnueabi-g++
当我选择g++时,一切都很好,并且可以编译。但当交叉编译时,我会得到:
error: 'close' was not declared in this scope
这是简化的源代码
#include <iostream>
#include <fcntl.h>
using namespace std;
int fd;
int main() {
cout << "!World!"
我想让我的项目在Linux上可用。因此,我需要替换windows.h库中的函数。
在我的terminal.cpp中,我用红色突出显示错误消息。我只想在windows中执行这个步骤(ANSI不适用于我的控制台,因此我没有跨平台的解决方案)。
在windows上,它可以工作,但是在Linux上,我得到了以下错误:
/usr/bin/ld: /tmp/ccvTgiE8.o: in function `SetConsoleTextAttribute(int, int)':
Terminal.cpp:(.text+0x0): multiple definition of `SetConsoleT
#include <iostream>
using namespace std;
void calc () {
double num1, num2, result;
char op;
cout << "Enter your first number \n";
cin >> num1;
cout << "Now enter your second number \n";
cin >> num2;
cout << "And last
我正在尝试在linux (linux Mint8)中运行我的第一个c++程序。我使用的是gcc或g++,两者都有相同的问题:编译器找不到我试图导入的库。
我怀疑我应该复制工作文件夹中的iostream.h文件(我不知道在哪里查找它),将我的文件移动到其他地方进行编译,或者使用某种选项。
谢谢你的建议。
以下是gcc命令、c++代码和错误消息:
gcc -o addition listing2.5.c
。
#include <iostream.h>
int Addition(int a, int b)
{
return (a + b);
}
int main()
{
我意识到有几件这样的复制品,但到目前为止没有一件对我有用。我试图使用C++在Ubuntu上编译一个非常简单的g++程序,但是它给了我范围错误。
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world";
}
--这给了我一个错误:
sudo g++ -v test.c
test.c: In function ‘int main()’:
test.c:7:3: error: ‘cout’ was not declared in this scope
我还试着
最近,我无意中遇到了“在此范围内未声明”的多次错误,如下所示:
/usr/include/c++/9/ext/string_conversions.h:84:25: error: ‘ERANGE’ was not declared in this scope
84 | else if (errno == ERANGE
| ^~~~~~
In file included from /usr/include/c++/9/system_error:39,
from /usr/include
我正在尝试编译Boost Calc6示例:
通常情况下,在我的Mac上使用Xcode时,这是没有任何问题的。目前,我在一台使用VS2013的PC上。在创建Win32控制台应用程序时,我已经在标准设置中添加了一些东西。通常,它会给你设置一个ProjectTitle.cpp和stdafx.cpp (里面只有#include "stdafx.h“)。
下面是Calc示例中包含"main“的文件
#include "calc6.hpp"
#include "stdafx.h" /* I ADDED THIS, AS IT COMES AS BOILER
我使用的是我创建的对象和内置的向量类型。当我将变量设置为成员函数中的参数时,编译器抛出一个错误,抱怨变量的类型。我不确定为什么,因为编译器通过突出显示它们来将它们识别为对象,所以我不确定错误是什么。 错误发生的位置 #pragma once
#include "board.h"
#include "player.h"
#include "humanPlayer.h"
#include <vector>
class Game {
private:
int winner;
int X;
int Y;
b
#include <string>
#include <iostream>
using namespace std;
//-----------------------------------------------------------------//
//-------------------------class employee--------------------------//
//-----------------------------------------------------------------//
class Employee
{
p
例如,我有两个cpp文件: f1.cpp和f2.cpp,还有一个头文件: xxx.h。
f1.cpp有以下源代码:
#include <iostream>
#include "xxx.h"
using namespace std;
int main ()
{
rect rplace;
polar pplace;
cout<<"Enter the x and y values: ";
while (cin>>rplace.x>>rplace.y)
{
ppl
我最近购买了Bjarne Stroustrup的"Programming: Principles and Practice Using C++“一书,并一直在阅读它。我目前被困在一个早期的项目中,我需要输出一些文本字符串。使用Visual Studio Community 2015更新1,在Windows 10 Lenovo Yoga 2 Pro笔记本电脑上,我试图编译该项目,但遇到了详细的错误:
“无法打开预编译头文件:Debug\ file Upstairs Bathroom.pch':没有这样的文件或目录”。该项目的名称恰如其分地命名为“查找上楼Bathroom.cpp”
我正在尝试运行最小的 (为了方便起见)
#include <iostream>
#include <armadillo>
using namespace std;
using namespace arma;
int main()
{
mat A = randu<mat>(4,5);
mat B = randu<mat>(4,5);
cout << A*B.t() << endl;
return 0;
}
我正在运行linux 23发行版,并安装了armadillo包。
$ sudo dnf l
我的代码在Visual和windows中运行良好,但在Xcode中我遇到了很大的问题。首先,我想知道在删除了direct.hinclude之后(在Xcode中,mac),我得到了以下错误
而且,我创建的类中的对象(这与Direct.h无关)都无法初始化。Xcode似乎不理解我的任何构造函数。错误消息如下所示。这个例子是针对我的一个对象的。有什么帮助吗?
这是我的一堂课。请不要所有的类都没有装载!!
class p_args{
public:
string ts,par,fxd,dir,dato;
int diFL, RSQtype, runt
因此,我从souceforge下载了soci 4.0.0并将其解压缩到/tmp/中。然后:
cd /tmp/soci-4.0.0
mkdir build
cd build
cmake -G "Unix Makefiles" -DWITH_BOOST=OFF -DWITH_ORACLE=OFF -DSOCI_TESTS=ON -DWITH_SQLITE3=ON -DSOCI_SQLITE3_TEST_CONNSTR="test.db" ../
make
make test
我得到了:
Running tests... Test project /tmp/soci-
我正在用我自己的头文件用C++编写一个程序。
main.cpp
#include<iostream>
#include"operation.h"
using namespace std;
main()
{
int a;
cout <<"Enter the value a";
cin>>a;
//class name add
//obj is object of add
add obj;
obj.fun(a);
}
operation.h
class add
{
void fun(int
我有一个正在做的c++项目。我现在有点迷惑了。我需要一点帮助。我需要在main.cpp文件中实现.h文件中的代码,但我不确定如何实现。
例如来自main.cpp的代码代码:
switch (choice){
case 1: // open an account
{
cout << "Please enter the opening balence: $ ";
cin >> openBal;
cout << endl;
cout << "Please enter the account