Comments (26)
Also, i dont know how to compile a cpp file either. I just get 3 *.a files and 1 *.dylib file, now where should i place them to comile a cpp file successfully? like, the tiger_antelope problem. Dying for an example :(
from ai-toolbox.
Ideally, if you compile everything, you should have already the binaries for the examples working.
Also, if you run the tests, do the Python tests run correctly? Have you tried running the Python CLI in the same folder as the dylib
file? It is possible that the CLI was simply not finding the dynamic library you compiled.
from ai-toolbox.
In the build folder you should have an examples
folder, if you go in there there should be the compiled executables of the examples.
from ai-toolbox.
the ctest shows that all python related tests failed, the rest passed, but i guess that's due to some problems with anaconda, i will try without anaconda later.
right now my problem is that, i have all the libraries, and i want to compile a cpp file, how can i do that. Like, where should i put the 4 library files, and what flags should i add when gcc
from ai-toolbox.
The .a
files are static libraries, that you can link to your code. Usually you simply pass them to the compiler with the -l
flag.
This post gives you an example: https://stackoverflow.com/questions/5870026/howto-add-a-static-library-a-into-a-c-program
from ai-toolbox.
so i don't need the AIToolbox.dylib file for compiling c++ right? Like, the .a files are purely for c++ compiling, and the .dylib file is purely for python?
from ai-toolbox.
Yes, exactly.
Do let me know if you have problems compiling an example, I can try to make a one-liner to let you compile something and see if it works.
from ai-toolbox.
So, this is what i am doing. I go to the example folder, which is "/AI-Toolbox-master/examples/MDP", and i copy the file "libAIToolboxMDP.a" there, and I run "g++ -L. tiger_antelope.cpp -l libAIToolboxMDP.a", and it still shows " 'AIToolbox/MDP/Algorithms/ValueIteration.hpp' file not found "
command "g++ -L. tiger_antelope.cpp -l libAIToolboxMDP", "g++ -L. tiger_antelope.cpp -l AIToolboxMDP" have also been tried and no luck
from ai-toolbox.
and the command " g++ tiger_antelope.cpp libAIToolboxMDP.a ", which is suggested in your link, also wont work
from ai-toolbox.
So, when you compile C++ the compiler still needs to be able to see the header files as they are included in the tiger_antelope.cpp
file you are compiling. The static library contains the "precompiled" definitions of the library (the part in the src
folder), but you do need the include
part of the library wherever you go. To do this it should simply a matter of adding a -I/AI-Toolbox-master/include
(that's an upper case i, not l) to the command. This tells the compiler to look for additional include files in that directory.
from ai-toolbox.
On my system, if I go inside the examples/MDP
folder, this command is enough to compile the example:
g++ -std=c++17 tiger_antelope.cpp -I ../../include/ -L ../../build/ -l AIToolboxMDP -I /usr/include/eigen3/
from ai-toolbox.
If you still can't manage, I think I have a bare-bones CMake project somewhere that I could post on GitHub to help you. I need to find it and clean it up a bit so it might have to wait until tomorrow though.
Let me know.
from ai-toolbox.
right! and that works for me too! Thanks a lot!
And one more question, i have not finished uninstalling the anaconda, but i still wanna ask what is the case with python? Like, what should i do to run a python script?
from ai-toolbox.
Ideally your Python script should simply have an import AIToolbox
inside, and everything should work (you can also test the import directly from CLI). It should be able to find the dylib
file obviously. If you look at the Python examples they simply use the import and that's it.
from ai-toolbox.
Now what i m doing, is that I make a new directory on the desktop, i put the library "AIToolbox.dylib" in the directory, i put another script.py in the directory, with the code :
import AIToolbox
print("hello")
and it says
"
File "script.py", line 1, in
import AIToolbox
ModuleNotFoundError: No module named 'AIToolbox'
"
from ai-toolbox.
I'm really not sure to be honest. Could it be that you are calling a different Python version than the one you compiled with? It happened to me a couple of times by mistake.
from ai-toolbox.
Well, it seems that the problem is within boost-python. I have no idea how to correctly install boost-python. Would you mind sharing how you install boost and boost-python step by step? The tutorials i googled all seem really messy~~
from ai-toolbox.
I am guessing you are on Mac; I work on Linux and for me installing boost-python is a one-liner on the command line. I don't really have Mac experience nor I have tested the library there (although I believe many people on Mac have used the library successfully before).
from ai-toolbox.
Then have you tried on windows? my windows says
"could not find boost(missing : python38)"
when running cmake -DMAKE_PYTHON=1 ..
from ai-toolbox.
The windows set up is stuck on the boost python problem, and I v search around and found that maybe python is having problem recognizing the .dylib type file. Is there any way I can generate a .so file on mac instead?
from ai-toolbox.
I have tested Windows, and it works, but it is a bit more annoying due to the fact that CMake has a harder time finding the libraries (as on Windows they generally don't have "standard" paths). So you basically have to specify manually most of the paths.
You could give a look at issue #32. In particular here I mention a couple of flags for Boost, but the issue has more information overall so you still might want to read through it.
from ai-toolbox.
Regarding the .so
vs .dylib
, this is mostly just nomenclature which depends on the system, they are equivalent. On Windows there are .dll
which are also basically the same.
from ai-toolbox.
I switched to a linux system on server and the .so file now works fine
Due to the lack of root privilege, i have to install every package from source
The followings are the stepes i v taken
specify g++ include and lib path
make directory /bin /include and /lib under $HOME, and then export them to system path:
export C_INCLUDE_PATH="$HOME/include:$C_INCLUDE_PATH"
export CPLUS_INCLUDE_PATH="$HOME/include:$CPLUS_INCLUDE_PATH"
export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"
export LIBRARY_PATH="HOME/lib:$LIBRARY_PATH"
put these lines in .bashrc so that g++ can find the headers and libs when compiling and linking
install cmake, eigen, lp_solve, anaconda
Then i installed cmake with prifix setting to $HOME :
./bootstrap --prefix=$HOME
make
make install
export the path of cmake to make it reachable by terminal (still in .bashrc)
export PATH="$HOME/bin:$PATH"
download eigen and lp_solve source files, put .h files in $HOME/include and .so, .a files in $HOME/lib . They should now be reachable by g++ and cmake
next install anaconda and create a new environment ENV, i installed anaconda under $HOME. add python to system include path
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$HOME/anaconda3/envs/ENV/include/python3.8"
export C_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$HOME/anaconda3/envs/ENV/include/python3.8"
In addition, python-dev needs to be installed to enable boost python:
pip install python-dev-tools
install boost
to install boost, first i downloaded the source file. Most boost functions are in .h files, so just copy them to the include path:
cp -r /boost_1_68_0/include $HOME/
some libraries need to be compiled and install, the following are my commands:
./bootstrap.sh --with-python=$HOME/anaconda3/envs/ENV/include/python3.8 --with-python-root=$HOME/anaconda3/envs/ENV/include/python3.8 --prefix=$HOME
./b2 install -a --with=all
boost python should now work fine
install AIToolbox
some modifications are made to cmakelist.txt, findeigen3.cmake, findlpsolve.cmake, mostly some paths are set specifically, so that eigen, lp_solve and boost can be found properly
in findeigen3.cmake
set(EIGEN3_INCLUDE_DIR $HOME/include)
in findlpsolve.cmake
SET(LPSOLVE_INCLUDE_DIR "$HOME/include" CACHE STRING "Full path to the lpsolve headers")
SET(LPSOLVE_LIBRARIES "$HOME/lib" CACHE STRING "Full path to the lpsolve55 library (including the library)")
If cmake still cannot find the proper headers or libs, try setting NO_DEFAULT_PATH
to function find_package(...)
or find_library(...)
in cmakelist.txt
set(BOOST_ROOT $HOME)
set(Boost_INCLUDE_DIR $HOME/include)
set(Boost_LIBRARY_DIR $HOME/lib)
Now the ctest should run well on python.
In most cases bugs occur due to cmake unable to find package, or unable to locate the right version of package, thus paths should be set manually in .cmake and cmakelist files. debug message can be echoed by commands like
message($Python_INCLUDE_DIRS)
to check if the right version of package is found
Thanks for all the help from @Svalorzen !
from ai-toolbox.
Wow, nice job! Thanks a lot for reporting all the steps you took to make it work! Feel free to open more issues if you have questions about the library :)
Can I ask you what you'll be using the toolbox for? I'm just curious :)
from ai-toolbox.
I am a university student and i ll be using the toolbox for a project related to POMDP. I m only responsible for part of the project and so have not yet got the whole picture. I will surely open more issues should there be more interesting things to discuss
Thank you a lot for your patience and the AIToolbox you write. You are bringing a lot convenience to learners of MDP and POMDP like me!
from ai-toolbox.
Happy to be of help! I'll close this issue then now since it looks like you have things under control.
Good luck with your project!
from ai-toolbox.
Related Issues (20)
- Using the Toolbox to solve the Tag problem HOT 4
- Save POMDP policy HOT 6
- Sparse Matrix's on POMDP model HOT 22
- Improve serialization for MDP and POMDP Sparse Models HOT 1
- Problem with make HOT 5
- Make cannot find .hpp file in Boost HOT 2
- Errors when compiling tutorials HOT 5
- Can't find Lpsolve when run cmake HOT 9
- Using AI-Toolbox with OMNeT++ HOT 2
- Make issue HOT 9
- Not able to find "compare" file HOT 3
- Trouble installing and running AIToolbox HOT 9
- about LP_Solve HOT 13
- error C3779: 'AIToolbox::IndexMapIterator<IdsIterator,Container>::operator *': a function that returns 'auto' cannot be used before it is defined HOT 11
- Better Project Setup Tutorial HOT 6
- C++: error: expected โ)โ before โelementsNโ HOT 10
- Problems when building the library HOT 4
- Sparse Matrix: Space Time Complexity while assigning and accessing an element. HOT 1
- Can't build because of lpslove HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ai-toolbox.