Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fable build issue - missing binary operator before token #1045

Open
bdsmith0809 opened this issue Feb 12, 2025 · 3 comments
Open

Fable build issue - missing binary operator before token #1045

bdsmith0809 opened this issue Feb 12, 2025 · 3 comments

Comments

@bdsmith0809
Copy link

bdsmith0809 commented Feb 12, 2025

Problem running the 'make' command described in the installation instructions.

Running in Ubuntu

`
fable/modules/boost/boost/thread/pthread/thread_data.hpp:60:5: error: missing binary operator before token "("
60 | #if PTHREAD_STACK_MIN > 0
| ^~~~~~~~~~~~~~~~~

++ -o boost/libs/timer/src/cpu_timer.o -c -I/home/brian/Projects/Python/fable/modules/boost -fPIC -fno-strict-aliasing -w -DNDEBUG -O3 -funroll-loops -DBOOST_ALL_NO_LIB -DBOOST_SYSTEM_NO_DEPRECATED=1 -DBOOST_TIMER_DYN_LINK=1 -I/home/brian/Projects/Python/fable/modules -I/home/brian/Projects/Python/fable/modules/cctbx_project /home/brian/Projects/Python/fable/modules/boost/libs/timer/src/cpu_timer.cpp
g++ -o boost_adaptbx/graph/breadth_first_search_ext.o -c -pthread -DBOOST_PYTHON_MAX_BASES=2 -I/home/brian/Projects/Python/fable/modules/boost -fPIC -fno-strict-aliasing -w -DNDEBUG -O3 -funroll-loops -DBOOST_ALL_NO_LIB -I/home/brian/Projects/Python/fable/modules/cctbx_project -I/home/brian/Projects/Python/fable/build36/include -I/home/brian/Projects/Python/fable/modules -I/home/brian/Projects/Python/fable/modules/cctbx_project -I/home/brian/Projects/Python/fable/build36/include -I/home/brian/miniconda2/envs/fable36/include/python3.6m /home/brian/Projects/Python/fable/modules/cctbx_project/boost_adaptbx/graph/breadth_first_search_ext.cpp
scons: *** [boost/libs/thread/src/pthread/thread.o] Error 1
scons: building terminated because of errors.
usr+sys time: 1.01 seconds
wall clock time: 48.93 seconds
make: *** [Makefile:6: default] Error 2

`

@bkpoon
Copy link
Member

bkpoon commented Feb 12, 2025

This is from the Boost source that is included in our source that is for older distributions of linux. If you are on Ubuntu 18 or later, you can delete the modules/boost directory before building. You should also delete your build directory before trying to build again because that might have some compiled Boost code.

@bdsmith0809
Copy link
Author

bdsmith0809 commented Feb 13, 2025

Deleting the modules/boost folder caused the build to fail. Somewhere, something during the Make process is looking for boost python bindings. I had to install boost manually in the conda environment to get past that point.

Is there any sort of quick readme on how to use fable for Fortran files on a local machine? The automated tests are a good start, but there seems to be a lot of python programmatic magic going on, and it's hard to tell how one should start converting code of my choosing.

@bkpoon
Copy link
Member

bkpoon commented Feb 24, 2025

The basic command can be

fable.cout <fortan file 1> <fortan file 2> <additional fortran files> > <output cpp file>

You can add the --namespace flag to define the namespace for the C++ code.

As an example, you can try converting the LBFGS code in our scitbx/lbfgs directory by going into the cctbx_project directory of the repository and running

cd cctbx_project
fable.cout scitbx/lbfgs *.f > a.cpp

There are 2 Fortran files, one for the LBFGS code (lbfgs.f), and one for the driver (sdrive.f). You can convert them separately into different C++ files and then compile them together as well.

To compile, you will need some header files in cctbx_project, so in the compilation command, you will need -I flags to specify them.

g++ -I . -I ./fable a.cpp

The fable.cout --example will also show the full path for the -I flags.

You should get a.out which can be executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants