I'd like to use the Boost library in my C++ code, so I've inputted the right include search path and the right library search path, then I added all the Boost library files in Xcode. When I build my code the compiler says that the build is successful. However, once I run the code, the console tells this:
Console:
dyld: Symbol not found: _PyBaseObject_Type
Referenced from: /usr/local/lib/libboost_python27.dylib
Expected in: flat namespace
in /usr/local/lib/libboost_python27.dylib
Program ended with exit code: 9
My code:
#include <iostream>
#include <boost/any.hpp>
int main()
{
std::cout << std::endl;
return 0;
}
Where is my mistake? Please help.
This error occurs when you don't add a package to your project the right way. The problem has resolved in my example by installing Boost via Homebrew. Installing the package the right way means that if you install it manually (e.g. downloading it from GitHub), you should install it on the right path. But I suggest always installing C++ packages via Homebrew.
Related
I installed Aspose.Cells and tried to write a simple C++ file that includes Aspose.Cells.h. I soon realized that I had to install two other external libraries, boost and icu4c as without these libraries my compiler would throw errors saying some h or hpp files can not be found.
My problem is: even after I installed these libraries, I still couldn’t compile my code, as I received a new error saying “Fatal ERROR: comdef.h: No such file or directory.”
And the error persisted even after I installed the latest version for SDK for Win 10.
My simple file can run if I remove the line "#include Aspose.Cells.h" .
Can someone please enlighten me as to how to solve this error?
Also I noticed there is a folder called “Publish” under “include” folder for Aspose.Cells. This folder is besides boost and icu. Could this mean Publish is the third external library to be installed? But I couldn’t find any library called Public on the web. Pls see the screenshot below.
directory of include folder that comes with the installed Aspose.Cells package
Thanks a lot!
My code is as follows:
#include <iostream>
#include <Aspose.Cells.h>
using namespace std;
int main() {
cout << "hello!!!" << endl;
return 0;
}
Regards
Hillary
Can someone please help me with my issue with Aspose.Cells library for C++?
I was writing my first C++ programme using Aspose.Cells library. Everything seemed smooth except that the following error was produced after I built the file:
Error before I launch is:
"Error exist in a required project.Continue launch?"
Error after running the code is:
"**fatal error: boost/config/compiler/gcc.hpp: No such file or directory**".**
If I commented out the line #<include Aspose.Cells.h>, the file can run with no errors.
I tried to solve the error by installing Boost library for C++ from zip file "boost_1_73_0", as I think Aspose depends on Boost to run. However, I couldn't link to Boost successfully as there doesn't seem to be a "include" folder and "lib" folder for me to add into project properties.
My questions are:
Will installing Boost solve my problem?
If yes, how can I install Boost library successful?
The following is my code in C++. Thanks a Lot in advance!
#include <iostream>
#include <Aspose.Cells.h>
using namespace std;
int main() {
cout << "!!!I am little red!!!" << endl;
return 0;
}
Regards
Hillary
UPDATE: I have successfully installed and linked Boot library now but I have got three warning message upon building: "Ignoring #pragma warning [-wunknown-pragmas]" , are these warning messages serious?
I also ran into another fatal error: unicode/uloc.h:No such file or directory. How can I correctly link up to unilib-master/Unicode library?
Yes, installing Boost helps.
If Aspose only requires header-only libraries from Boost, then you don't have to do much. The "include" path you're looking for is just the folder where you extracted the zip. The actual library headers are under boost/ in that folder, which are then found by the compiler.
If you need the shared libraries, you will need to build them. Follow the steps here Getting Started On Windows
I have followed the instructions in the following document to the letter (including the instructions for building mongo-c-driver): https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/
I am attempting to build the sample code provided (using VS2015), which I shall copy paste for convenience:
#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
int main(int, char**) {
mongocxx::instance inst{};
mongocxx::client conn{ mongocxx::uri{} };
bsoncxx::builder::stream::document document{};
auto collection = conn["testdb"]["testcollection"];
document << "hello" << "world";
collection.insert_one(document.view());
auto cursor = collection.find({});
for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
}
}
I have specified the header and library include directories according to the project settings provided. I have also added the MONGOCXX_STATIC and BSONCXX_STATIC preprocessor definitions.
Initially I added the following libs to the linker settings: libmongocxx.lib;libbsoncxx.lib;mongoc-static-1.0.lib;bson-1.0.lib;
When compilation failed I tried using the static bson lib (not sure why the documentation suggests using the non-static one?), so my input libs are now as follows: libmongocxx.lib;libbsoncxx.lib;mongoc-static-1.0.lib;bson-static-1.0.lib;
Despite my best efforts, and frantic googling, I get around 2000 unresolved externals, an example of which I've copied and pasted below:
libmongocxx.lib(distinct.obj) : error LNK2001: unresolved external symbol __imp_mongoc_read_prefs_new
It appears as though it is coming from mongo c driver. I have seen this SO article, but I am already linking mongoc-static-1.0.lib as stated above - unfortunately there is little else to go on in this post. The compiler is clearly finding said lib (otherwise it would complain with "not found" errors), so I can only think that I have somehow built the lib incorrectly.
I'll also mention at this point that I have successfully built and run the code using the non-static libs and dlls - however, it is highly desirable to avoid having to use dlls and so I would like to use the static libs if possible.
I have read the installation instructions several times now, and something that sticks out at me is the following:
If you need static libraries, be sure to use the --enable-static configure option when building libmongoc.
However, this appears to be appropriate only for installing in Linux, I am installing in Windows using CMake. I ran CMake.exe -LH to see what available options there were in the hope of finding something about static libs, but no dice. It appears that there are no options necessary for building the static libs, since when I installed mongo-c-driver, I successfully obtained the bson-static-1.0.lib and mongoc-static-1.0 libs.
I find myself at a loss! Any help would be greatly appreciated, cheers.
Have you resolved the problems? I have similar problems. However, it seems fine if you use older drivers, like mongoc 1.4, bson 1.4 and mongocxx 3.0, though they can only support mongodb 3.2 and older
I am on a Mac OSX and I am trying to start using the C ftdi drivers I installed using brew
brew install libftdi
That installed the library in the directory /usr/local/Cellar/libftdi/1.2 And I have the following C++ code
#include <iostream>
#include <ftdi.h>
using namespace std;
int main() {
struct ftdi_context ftdi;
ftdi_init(&ftdi);
cout << "Hello World" << endl;
return 0;
}
How should I compile this to make it work? I am including the include/ directory so the compiler can find the header file but I do not know which object file should be linked. I am trying to using the following command
g++ -I /usr/local/Cellar/libftdi/1.2/include/libftdi1/ /usr/local/Cellar/libftdi/1.2/lib/libftdi1.a test.cpp
But I am getting bad linker errors even though I have included the .a file. The lib/ directory has the following contents
cmake
libftdi1.2.2.0.dylib
libftdi1.2.dylib -> libftdi1.2.2.0.dylib
libftdi1.a
libftdi1.dylib -> libftdi1.2.dylib
pkgconfig
Is there something else I should try and link it to? Even if you are not aware of this particular driver is there something in general that I should be doing for drivers like this that I have not done?
Thanks for the help!
not particularly good with this kind of stuff I have managed to install the Boost C++ library and this basic program works with the g++ compiler and linking to the right .dylib files.
#include <iostream>
#include <boost/filesystem.hpp>
using namespace boost;
int main()
{
filesystem::path path1("/Users/username/Documents/testfile.txt");
filesystem::remove(path1);
std::cout << "It worked" << std::endl;
return 0;
}
Now I would like to do the same, just using Xcode to build and run the program, but it doesn't work. I have done everything in this tutorial:
http://buddypanda.com/?p=10
i.e. include header and library search paths, as well as linked the .dylib files of filesystem and system under the 'Build Phases' tab.
The Build succeeds but then the program crashed with an error of EXC_BAD_ACCESS.
I can maybe provide more specifics on what goes wrong if you tell me where to look.
Thanks!
EDIT1: I am using g++-4.9 and Boost-1.58 and Xcode 6.4