I'm trying to use boost on CodeBlocks. I have codeblocks configured with MinGW-w64. I alredy have included the following libraries in the linker settings
libboost_system-mgw73-mt-d-x32-1_66.a
libboost_system-mgw73-mt-x64-1_66.a
libboost_filesystem-mgw73-mt-x64-1_66.dll.a
I also try changing the order...
This is the source code
#include <iostream>
#include <boost/filesystem.hpp>
using namespace std;
namespace fs = boost::filesystem;
int main(int argc, char* argv[])
{
if( fs::is_directory("."))
cout << "Works!" << endl;
return 0;
}
i have read many "solutions" but they didn't work.
i tried:
changing the #include for this
#define BOOST_NO_CXX11_SCOPED_ENUMS
#include <boost/filesystem.hpp>
#undef BOOST_NO_CXX11_SCOPED_ENUMS
creating a new compiler flag with boths values
-lboost_filesystem-mt
and also
-lboost_filesystem
but i always get the same error
...\boost_1_66_0\boost\filesystem\path.hpp|981|undefined reference to `boost::filesystem::path::codecvt()'|
Related
I have a simple program that compiles fine but fails to link due to my passing a wide string to std::stof. If I pass a standard non-wide string to stof, the program compiles and links with no issues.
#include <iostream>
#include <string>
int main(int argc, char** argv)
{
using namespace std;
float f = stof(wstring(L"53.42"));
cout << f;
return 0;
}
c:/mingw/lib/gcc/mingw32/9.2.0/include/c++/bits/basic_string.h:6636: undefined reference to `wcstof'
I'm compiling with mingw 9.2.0 and have tried linking mingwex manually, but doing so doesn't make a difference. g++ main.cpp -lmingwex
What is the problem?
I have built Boost from the website using
./bootstrap.sh
./b2 install
I think all are installed properly. I have headers in /usr/local/include/boost and libs in /usr/local/lib.
Everything links as long as don't include boost/thread.hpp:
//
// main.cpp
// ising3
//
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
#include <boost/tuple/tuple_io.hpp>
#include <iostream>
#include <boost/date_time.hpp>
//#include <boost/thread.hpp>
using namespace ::boost::tuples;
using namespace ::boost;
int main(int argc, const char * argv[])
{
// insert code here...
std::cout << "Hello, World!\n";
tuple<int,int> a,b,c;
a=make_tuple(1,1);
b=make_tuple(3,2);
std::cout<<a;
return 0;
}
Runs and prints:
Hello, World!
(1 1)
However, if uncommented, it fails:
I have linked the dynamic library libboost_thread.a and libboost_thread.dylib and included /usr/local/include into header search path and /usr/local/lib into library search path.
You should also link to boost_system.
The error indicates that it needs boost::system::system_category (which exists for error reporting).
I have built the LLVM using CMake using VS 2012 in keeping with documentation. I am trying to build a toy compiler with flex, bison and LLVM. The final stage of my compiler my main class looks like this:
#include <iostream>
#include "codegen.h"
#include "node.h"
#include "llvm/Target/Targetmachine.h"
using namespace std;
extern int yyparse();
extern NBlock* programBlock;
void createCoreFunctions(CodeGenContext& context);
int main(int argc, char **argv)
{
yyparse();
std::cout << programBlock << endl;
InitializeNativeTarget();
CodeGenContext context;
createCoreFunctions(context);
context.generateCode(*programBlock);
context.runCode();
return 0;
}
As stated in my previous post LLVM 3.4 linker errors in VS 2012. To workaround the solution I manually added the x86 files I was missing (taking clue from the errors). I ended up adding the following to the main:
#include "llvm-3.4/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h"
#include "llvm-3.4/lib/Target/X86/InstPrinter/X86ATTInstPrinter.h"
#include "llvm-3.4/lib/Target/X86/InstPrinter/X86IntelInstPrinter.h"
#include "X86MCAsmInfo.h"
#include "llvm/ADT/Triple.h"
#include "llvm/MC/MCCodeGenInfo.h"
#include "llvm/MC/MCInstrAnalysis.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MachineLocation.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/TargetRegistry.h"
#include "X86GenRegisterInfo.inc"
#include "X86GenInstrInfo.inc"
#include "X86GenSubtargetInfo.inc"
But I noticed that the following are missing from my system:
"X86MCAsmInfo.h"
"X86GenRegisterInfo.inc"
"X86GenInstrInfo.inc"
"X86GenSubtargetInfo.inc"
I looked through the online documentation but I am a beginner on the topic, most of it did not make too much sense to me. I would appreciate if someone could guide me or point me to the right tutorial which gives me a better understanding of what I am doing wrong here.
I installed Netbeans and as C++ compiler I installed cygwin. I made a simple project to test out my installation, this is the code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout << "test";
return 0;
}
This is the error message that it gives: http://pastebin.com/jRRh7MPi
I hope you guys can help me out.
You need to either explicitly link to C++ standard library, or compile using g++ instead of gcc.
I'm completely new to C++, but I have created a minor program, looking to port the program to other computers, but when I "install" the program I get this error...-static-libgcc -static-libstdc++ missing, is there a file I should be including in the program itself, or is this a library I have to install on each computer? The computers that I expect to run the program will be windows xp. Source code of the file is as follows:
#include <stdlib.h>
#include <windows.h>
#include <direct.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;
int main(int argc, const char *argv[])
{
_chdir("C:\\Program Files\\NCHSoftware\\Talk\\");
string number = "start talk.exe -dial " + std::string(argv[1]+4);
system(number.c_str());
exit;
return 0;
}
They are shared lib's that would need to be on the host computer.
To learn how to compile a static version;
See here: http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
Read the "-static-libgcc" & "-static-libstdc++" sections.