我正在尝试在新计算机上设置我的Code :: Blocks工作环境,但我遇到了一些问题.自从我第一次这样做以来已经很长时间了,现在当我打开我的主要项目时,Boost给我带来了问题.
我对C++还很陌生,修复这类问题是我经验不足的.
当我打开我的项目并尝试编译它时,我收到此错误:
致命错误:boost/algorithm/string.hpp:没有这样的文件或目录
在我的一个头文件的这一部分:
#include <boost/algorithm/string.hpp>
Run Code Online (Sandbox Code Playgroud)
我将Boost v1.51.0库放在C:\ boost中,因为那是我在其他计算机上使用它的地方.我的项目设置为搜索该目录以获取其他包含,但它似乎没有找到文件?
我的项目之前使用的是较早版本的Boost,但我怀疑这是一个问题.
我不确定用这些有限的信息来调试这个问题是多么困难,所以如果还有什么我能提供的,请告诉我.
我正在使用Code :: Blocks,并且刚刚设置了minGW和Visual C++ 2010.
如何关闭Windows上CodeBlocks中的"拼写检查功能"功能?
我现在才意识到,如果我在评论的末尾添加一个"\"(反斜杠),那么如果代码也被注释,则下一行.这一直是c ++的标准吗?

我需要在Codeblocks 16中启用C++ 11.
几个教程解释说,所有人需要做的是选择"让g ++遵循-std=c++11"设置>编译器...>编译器设置>编译器标志中的C++ 11 ISO C++语言标准选项",但是这样的选项不会出现在我的编译器标志:
其他人建议只是粘贴-std=c++11到"其他编译器选项".但是,这不允许我构建我的代码并在"构建消息"栏中显示:
我正在使用Codeblocks 16,以及Windows 7附带的GNU GCC编译器.
我正在使用MinGW的代码块,我正在尝试使用静态链接编译一个简单的程序.我已经使用这些方向构建了Boost库.一切都很好,我能够成功编译这个简单的程序(它编译,我知道它不起作用,因为它在消息发送到控制台之前退出,但我只是想让它编译).
如果我的链接器库中有一个DLL,它编译得很好,但当我用相同内容的静态.a库切换它时,我得到未定义的引用,例如"未定义引用`_imp ___ ZN5boost6threadD1Ev'|".
我不知道问题是什么,也无法找到解决方案.我认为这可能与链接器设置有关,但我找不到有关如何更改它们的信息.我将非常感谢可以提供的任何帮助.
#include <iostream>
#include <boost/thread.hpp>
void myfunction()
{
std::cout << "this is a thread" << std::endl;
return;
}
int main()
{
boost::thread mythread(&myfunction);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 假设我有以下数组:
arr = [[5, 1], [2, 7]]
Run Code Online (Sandbox Code Playgroud)
我想找到最小元素,比较元素的第二个元素.最小元素将是[5, 1]因为1小于7.我可以使用以下代码:
arr.min {|a,b| a[1] <=> b[1]}
Run Code Online (Sandbox Code Playgroud)
为了计算最大值,我也可以这样做:
arr.max {|a,b| a[1] <=> b[1]}
Run Code Online (Sandbox Code Playgroud)
这给了[2, 7].
我一直使用相同的块.我想在某处拥有该块并将其提供给min/max函数.我希望这样的事情:
blo = lambda {|a,b| a[1] <=> b[1]}
arr.min blo
Run Code Online (Sandbox Code Playgroud)
会工作,但它没有.有关如何做到这一点的任何想法?
我已经安装了Code :: Blocks for Windows,并希望编译C++ 14代码,如通用lambdas,但我从codeblocks.org安装的Code :: Blocks的二进制版本不支持该标志-std=c++14.
如何更新编译器并启用-std=c++14Code :: Blocks的标志?
我似乎无法弄清楚如何将程序参数添加到codeblocks调试器的启动命令.有人知道怎么做吗?
我在Ubuntu 10.10上使用Code :: Blocks.我已连接Mac键盘并将键盘设置设为"Swiss German Mac".现在每当我写一个等号,然后是一个空格(类似宽度= 100)我得到错误消息错误:stray'\ 302'在程序中.
我知道这个错误意味着文本文件中有一个非标准字符.
当我删除空格字符时,程序编译得很好.这意味着Code :: Blocks会添加某种特殊字符.但我不明白为什么会这样.任何人都有一个想法.
'\ 302'代表什么角色?
[更新]我进一步调查了这个问题.当我使用组合移位+空格时,我得到了这个迷路.现在我知道它不会经常发生.但它仍然相当烦人,特别是在编写代码时...有人知道是否有办法在X11中关闭这个组合?
[求助]感谢无用的回答,我能够解决"问题".它实际上更像是一个功能.Shift + space默认创建了spacenolinebreak.所以通过改变xmodmap
xmodmap -e "keycode 65 = space space space space space space"
Run Code Online (Sandbox Code Playgroud)
这个行为被覆盖了,现在一切正常.
谢谢!
链接我正在处理的项目时,链接器会出现以下错误:
/usr/bin/ld: ../Includes and Libs/lib/libsfml21rca.a(SoundFile.o): undefined reference to symbol 'sf_read_short@@libsndfile.so.1.0'
/usr/bin/ld: note: 'sf_read_short@@libsndfile.so.1.0' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libsndfile.so so try adding it to the linker command line
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libsndfile.so: could not read symbols: Invalid operation
Run Code Online (Sandbox Code Playgroud)
问题是,libsndfile.so已经在libsfml21rca.a之前链接了,所以我不知道问题出在哪里.
我正在使用Code :: Blocks 10.05
提前感谢您的帮助
编辑:
这是链接命令:
g ++ -L"包含和Libs/lib"-L"包含和Libs/lib/raknet3_731"-L"包含和Libs/lib/d3d_new/x86"-L"包含和Libs/lib/ogg"-L"包含和Libs/lib/sdl"-LBullet/lib -o(filename)...(很多目标文件)-lGLEW -lglfw -lGL -lGLU -lpthread -lopenal -ljpeg -lfreetype -lsndfile -lXrandr -lsfml-system -lsfml-window -lsfml-audio ../Bullet/lib/LinearMath.lib ../Bullet/lib/BulletCollision.lib ../Bullet/lib/BulletDynamics.lib"../Includes和Libs/lib/raknet3_731/RakNetLibStaticDebug.lib""../Includes和Libs/lib/libsfml21rca.a"../../../../../../home/msabol/Desktop/SFML/sfml2st/sfmlVideo/sfmlVideo/ bin/Release/libsfmlVideo.a ../../../../../../home/msabol/Desktop/SFML/sfmlVideo/bin/Release/libsfmlVideo.a
当我编译我的secrypt.cpp程序时,我的编译器显示错误" undefined reference to WinMain@16".我的代码如下
secrypt.h:
#ifndef SECRYPT_H
#define SECRYPT_H
void jRegister();
#endif
Run Code Online (Sandbox Code Playgroud)
secrypt.cpp:
#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include "secrypt.h"
using namespace std;
void jRegister()
{
ofstream outRegister( "useraccount.dat", ios::out );
if ( !outRegister ) {
cerr << "File could not be opened" << endl;
exit( 1 );}
string a,b,c,d;
cout<<"enter your username :";
cin>>a;
cout<<"enter your password :";
cin>>b;
outRegister<<a<<' '<<b<<endl;
cout<<"your account has been created";
}
Run Code Online (Sandbox Code Playgroud)
trial.cpp
#include<iostream>
#include "secrypt.h"
using namespace std;
int main()
{
void …Run Code Online (Sandbox Code Playgroud)