Clemapfel / jluna

Julia Wrapper for C++ with Focus on Safety, Elegance, and Ease of Use
https://clemens-cords.com/jluna
MIT License
239 stars 12 forks source link

Error unsolved after troubleshooting: concept does not name a type #58

Closed FDemelas closed 7 months ago

FDemelas commented 9 months ago

Hello, I installed Jluna on my Ubuntu 20.04, and the tests were successfully passed.

Anyway, now I'm trying to construct a simple "hello world" test, but I'm finding an error error: unknown type name 'concept' concept to_julia_type_convertable = requires(T) [and others...] similar to the one that you already consider in the troubleshooting: error: concept does not name a type.

I tried all the solutions that you proposed in the troubleshooting: updated my compilers (I tried clang++-12 and g++-10) and
_add target_compile_features(<your target> PRIVATE cxx_std_20)_ after the target creation.

Do you have any suggestions to solve the problem? Thank you in advance.

P.S.: I'm calling cmake with:

_cmake .. -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12_

My CmakeList file is:

cmake_minimum_required(VERSION 3.12)

project(TestLib)

set(CMAKE_C_COMPILER "clang-12")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++-12")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v  -rpath" )#-lpthread")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

find_library(jluna REQUIRED 
    NAMES jluna
    PATHS /home/user/jluna/
)

find_package(jluna REQUIRED)

add_executable(test test.cpp)

target_compile_features(test PRIVATE cxx_std_20)

target_link_libraries(test PRIVATE
    "${jluna}" 
    "${/home/user/julia-1.9.2/lib/}"
)

target_include_directories(test PRIVATE
    "/home/user/jluna"
    "/home/user/julia-1.9.2/include/julia"
)
FDemelas commented 9 months ago

Just a little update. I was able to compile the program 'at hand' using:

g++-10 -c ./test.cpp -o test.o -I "/home/user/julia-1.9.2/include/julia/" -I "/home/user/jluna/" -O3 -std=c++20 -DNDEBUG -DCLANG_1200_0_32_27_PATCH -fpic g++-10 -o ./JLUNA_test test.o -L "/home/user/julia-1.9.2/lib/" -ljulia -L "/home/user/jluna/jluna/lib/" -ljluna -O3 -std=c++20 -DNDEBUG -DCLANG_1200_0_32_27_PATCH -fpic

anyway, at execution time I found another error:

./JLUNA_test: error while loading shared libraries: /home/user/julia-1.9.2/lib/libjulia.so.1: only ET_DYN and ET_EXEC can be loaded

Clemapfel commented 7 months ago

Sorry for the late reply, could you try a newer clang, such as 14 or 16? I don't see anything wrong with your cmake and the concept error is a typical parsing error that signals that the compiler used has not yet implemented C++20 concepts

I will try to reproduce this using clang 12 on my ubuntu machine

Clemapfel commented 7 months ago
clem@ubuntu:~/Workspace/jluna/build$ cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/clang++-12
-- Configuring done
-- Generating done
-- Build files have been written to: /home/clem/Workspace/jluna/build

clem@ubuntu:~/Workspace/jluna/build$ make
Consolidate compiler generated dependencies of target jluna
[  7%] Building CXX object CMakeFiles/jluna.dir
(...)
[100%] Linking CXX executable jluna_test
[100%] Built target jluna_test

clem@ubuntu:~/Workspace/jluna/build$ /usr/bin/clang++-12 -v 
Ubuntu clang version 12.0.1-19ubuntu3
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64

I tried to reproduce this and clang12 is definitely new enough, my best guess is that you are accidentally using an older clang version, for example your /usr/bin/clang could actually be a symbolic link to an older version

francescoDemelas commented 7 months ago

Hello, thank you for your help. Sadly I still find the same error. I tried also with clang16, but nothing changed:

cmake .. -DCMAKE_C_COMPILER=/usr/bin/clang-16 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-16 -- The C compiler identification is Clang 16.0.6 -- The CXX compiler identification is Clang 16.0.6 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/clang-16 - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/clang++-16 - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (0.4s) -- Generating done (0.0s) -- Build files have been written to: /home/user/provaJluna/build

but then the make command fails with the same error:

In file included from /home/user/provaJluna/test.cpp:1: In file included from /home/user/jluna/jluna.hpp:11: In file included from /home/user/jluna/include/exceptions.hpp:9: /home/user/jluna/include/typedefs.hpp:91:5: error: unknown type name 'concept' concept to_julia_type_convertable = requires(T) ^ [....]

I tried to reinstall both Jluna and Julia (to a newer version), but this did not solve the problem.

Clemapfel commented 7 months ago

I'm still actively investigating this issue, I'll try to write you up an example project you can just clone to eliminate any possible errors, the docs should have one anyway

Clemapfel commented 7 months ago

I created an example project for you.

Please run, in any public directory:

# in <path>
git clone https://github.com/clemapfel/jluna
cd jluna
git fetch
git checkout example
mv example ../jluna_example
cd ../jluna_example

The folder jluna_example in the directory you ran the above in contains a full cmake project that should hopefully just work. To compile it, run:

# in <path>/jluna_example
mkdir build
cd build
cmake ..
make
./jluna_example

If an error saying it can't find the jluna headers occurs, edit line 10 in jluna_example/CMakeLists.txt to the folder of the jluna includes, "/home/user/jluna" in your original cmake.

If this works, simply base your project off jluna_example, I formatted in a way so it's easy to edit.

Clemapfel commented 7 months ago

If this still gives the same error, please add the following lines to your (or jluna_examples) CMakeLists.txt

get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
    message(STATUS "${_variableName}=${${_variableName}}")
endforeach()

then run cmake .. again. It should print a long list of names, please post that list.

francescoDemelas commented 7 months ago

Thank you very much, with your example everything works fine. Finally, there was some problem in my file CMake. I tried to better understand where was the problem and it seems that it was not able to correctly find my installation of Jluna in my home, but I have no problems with the one in /usr/local/... You can close the issue, thank you again!