How to run CLion with SFML and CMake on Linux? Errors in Make and audio? - linux

I'm pretty new to installing, rearranging files, and somewhat writing code on Linux. When tasked to install CLion along with SFML and CMake, I've come into a lot of problems figuring out how to make them work. I'm currently using a Debian GNU/Linux bullseye/sid(copied straight from what I saw), so if there's anything specific about that, that'd be nice to know too.
The problem in particular that I'm encountering is when I decide to run my file. I get these set of errors.
/usr/bin/ld: attempted static link of dynamic object `/home/user/Development/sfmlbuild/lib/libsfml-audio.so'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/sfml_project.dir/build.make:88: sfml_project] Error 1
make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/sfml_project.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/sfml_project.dir/rule] Error 2
make: *** [Makefile:118: sfml_project] Error 2
This is what I have in my CMakeLists.txt as well, which I assume locates most of the SFML files, so CLion can use them.
cmake_minimum_required(VERSION 3.7)
set(PROJECT_NAME sfml_project)
project(${PROJECT_NAME})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -static")
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES main.cpp)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_executable(${PROJECT_NAME} WIN32 ${SOURCE_FILES})
else ()
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
endif ()
set(SFML_ROOT "/home/user/Development/sfmlbuild")
cmake_policy(SET CMP0074 NEW)
set(SFML_STATIC_LIBRARIES FALSE)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
find_package(SFML REQUIRED COMPONENTS audio graphics window system)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
endif ()
I'm unsure what to do from here, or if there's anything wrong in particular with how I have my CLion setup. I set my CMake application to the folder where I have my sfml_project. And my sfmlbuild which contains the Linux version of SFML, downloaded from the suit, is in a separate folder which is where the libsfml-audio.so is located inside of. As for the build, execution, and development part of the CLion program, I have the Toolchains to detect the Make, C compiler, and C++ compiler where I also left the profile that's available to default. Maybe those have to do with something that's wrong, but I'm honestly unsure what to do from here.
If anyone can provide me feedback, small or large, then I would greatly appreciate it and try to get back as fast as I can with responses on whether or not I've done certain things.
I furthermore apologize as this is my first time utilizing this website to ask for any questions, so if this is a question poorly done, I accept my inexperience, and I hope to do better next time.
---Edit Update---
I suppose I should've put what the errors were exactly as well, so I'll add them here too.
For make[3]: Error 1
# External object files for target sfml_project
sfml_project_EXTERNAL_OBJECTS =
sfml_project: CMakeFiles/sfml_project.dir/main.cpp.o
sfml_project: CMakeFiles/sfml_project.dir/build.make
sfml_project: /home/user/Development/sfmlbuild/lib/libsfml-audio.so
sfml_project: /home/user/Development/sfmlbuild/lib/libsfml-graphics.so
sfml_project: /home/user/Development/sfmlbuild/lib/libsfml-window.so
sfml_project: /home/user/Development/sfmlbuild/lib/libsfml-system.so
sfml_project: CMakeFiles/sfml_project.dir/link.txt
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/user/CLionProjects/sfml_project/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking CXX executable sfml_project"
//Line #88 is the next one which the error refers to.
$(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/sfml_project.dir/link.txt --verbose=$(VERBOSE)
For make[2], Error 2:
# All Build rule for target.
CMakeFiles/sfml_project.dir/all:
$(MAKE) -f CMakeFiles/sfml_project.dir/build.make CMakeFiles/sfml_project.dir/depend
//The next line is line 76 for which error 2 occurs with make[2].
$(MAKE) -f CMakeFiles/sfml_project.dir/build.make CMakeFiles/sfml_project.dir/build
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/user/CLionProjects/sfml_project/CMakeFiles --progress-num=1,2 "Built target sfml_project"
.PHONY : CMakeFiles/sfml_project.dir/all
For make[1], Error 2:
# Build rule for subdir invocation for target.
CMakeFiles/sfml_project.dir/rule: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/user/CLionProjects/sfml_project/CMakeFiles 2
//The next line is 83 for which make[1] occurs.
$(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/sfml_project.dir/all
$(CMAKE_COMMAND) -E cmake_progress_start /home/user/CLionProjects/sfml_project/CMakeFiles 0
.PHONY : CMakeFiles/sfml_project.dir/rule
The make error is as follows, Error 2:
# Build rule for target.
sfml_project: cmake_check_build_system
//The next line is 118 for the make error.
$(MAKE) -f CMakeFiles/Makefile2 sfml_project
.PHONY : sfml_project
I apologize for posting all of this information so late; I still don't quite understand too much, but I hope this gives some more information for aid.

One potential issue is your find_package flag, looking on at a project I've made I used
find_package(SFML 2.5.1 COMPONENTS graphics audio REQUIRED)
Try putting the version number
another issue, according to this website SFML_ROOT is replaced by SFML_DIR. Hers the website: https://en.sfml-dev.org/forums/index.php?topic=24070.0

Related

Why does/can my build access sysctl on Linux?

I inherited a C++ code with a dependency to OpenMPI that I want to delegate to Conan and CMake, and the automated build has a strange (to me at least) behavior related to sysctl that I want to understand.
How I tried to do it
I declared the required dependencies in my root CMakeLists.txt:
Note: I added the full list of requirements because I also suspect that some of them may be in conflict? That happened before with boost, that forced me to set explicitly zlib (if i remember correctly).
# stuff ...
conan_cmake_configure(
REQUIRES
zlib/1.2.12
mp-units/0.7.0
boost/1.79.0
openmpi/4.1.0
gsl/2.7
cspice/0067
GENERATORS
cmake
# that is required for cspice
CMakeDeps
CMakeToolchain
)
# more stuff ...
and then in the application CmakeLists.txt I find, include and link the executable to the required libraries:
add_executable(spock main.cpp)
find_package(cspice REQUIRED)
find_package(openmpi REQUIRED)
target_include_directories(
spock PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
openmpi_INCLUDE_DIRS
cspice_INCLUDE_DIRS
)
target_link_libraries(spock
CONAN_PKG::boost
CONAN_PKG::mp-units
openmpi::openmpi
cspice::cspice
)
# We need C++ 20 activated with the concepts library
target_compile_features(spock PUBLIC cxx_std_20)
Problem: undefined reference to sysctl ... on my local system only.
Building on my local machine with CMake 3.23.2 results in the following error message:
Consolidate compiler generated dependencies of target spock
[ 25%] Building CXX object src/CMakeFiles/spock.dir/main.cpp.o
^[[A^[[A[ 50%] Linking CXX executable ../bin/spock
/usr/bin/ld: /home/becheler/.conan/data/openmpi/4.1.0/_/_/package/8f7048d1bf6fc2a7985eb087c34e69a5e64f6c86/lib/libopen-pal.a(evutil_rand.o): in function `arc4_stir.isra.0':
evutil_rand.c:(.text+0x3d2): undefined reference to `sysctl'
collect2: error: ld returned 1 exit status
gmake[2]: *** [src/CMakeFiles/spock.dir/build.make:146: bin/spock] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:135: src/CMakeFiles/spock.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
However, the same build on Github workflows on Ubuntu 20.04 works. What is weird. The only difference before apart the distribution version is that github wokflows use higher privileges than me on local (I believe?).
What I tried so far
I've been trying to read about what this sysctlreference is. And I found conflicting information:
Frrom this man page:
The sysctl() function retrieves system information and allows processes with appropriate privileges to set system information.
this similar SO question came to the conclusion that
Linux does not support this function (other OS like MacOS or FreeBSD support it)
A comment from the same post concludes that in Linux,
these details can be obtained by reading the kernel-provided
pseudofiles /proc/cpuinfo and /proc/meminfo
So here is my question: why does it compile at all on the remote server if this command is not supposed to exist on the OS used?

Cmake vcpkg and Bullet

I am very much lost here and could really use some help.
I'm working on an Honours project for next year that involves a physics simulation using Bullet and Vulkan for rendering. After a few months of work I have most of the project functioning. It needs a lot of refactoring and cleaning which will be the next stage.
I have been using a makefile but wish to migrate to CMake for a few reasons. Mainly because it seems to be the standard and because I want to compile for different OS's in the future (I'm running Linux but may need to deploy on Windows or Mac). Finally, I was recompiling the whole project for even a small change, which was beginning to become a problem as I started Unit Testing more.
The old makefile is as follows :
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
OWN_INCLUDES = \
-I$(ROOT_DIR)/src/Domain \
-I$(ROOT_DIR)/src/Vk \
-I$(ROOT_DIR)/src/Ui \
-I$(ROOT_DIR)/src/Service
ADD_INCLUDES = \
-I/opt/bullet3-master/src \
-I/opt/vk_mem_alloc \
-I/opt/stb_image \
-I/opt/tiny_obj_loader/ \
-I/opt/imgui-vulkan/
BULLET_INCLUDE_PATHS_LIBS = -L/opt/bullet3-master/src/BulletCollision/ \
-L/opt/bullet3-master/src/BulletDynamics/ \
-L/opt/bullet3-master/src/LinearMath/ \
-lBulletDynamics -lBulletCollision -lLinearMath
VULKAN_SDK_PATH = /opt/Vulkan_SDK/1.2.162.1/x86_64
CFLAGS = -std=c++17 -I$(VULKAN_SDK_PATH)/include $(OWN_INCLUDES) $(ADD_INCLUDES)
LDFLAGS = -L$(VULKAN_SDK_PATH)/lib `pkg-config --static --libs glfw3` -lvulkan $(BULLET_INCLUDE_PATHS_LIBS)
IMGUI_CPP_PATHS = /opt/imgui-vulkan/*.cpp
OWN_CPP_PATHS = src/*.cpp src/Domain/*.cpp src/Vk/*.cpp src/Ui/*.cpp src/Service/*.cpp
###### Unit Testing Paths
UNIT_TEST_INCLUDE = -I/opt/catch-header/
UNIT_TESTS_PATH = $(ROOT_DIR)/unit_tests/*.cpp
VulkanRun: $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS)
g++ $(CFLAGS) -o VulkanRun $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS) $(LDFLAGS)
Unit_Test: $(UNIT_TESTS_PATH) src/Domain/*.cpp src/Vk/*.cpp src/Ui/*.cpp src/Service/*.cpp $(IMGUI_CPP_PATHS)
g++ $(UNIT_TEST_INCLUDE) $(CFLAGS) -o Unit_Test $(UNIT_TESTS_PATH) src/Domain/*.cpp src/Vk/*.cpp src/Ui/*.cpp src/Service/*.cpp $(IMGUI_CPP_PATHS) $(LDFLAGS)
VulkanDebug: $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS)
g++ $(CFLAGS) -g -o VulkanDebug $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS) $(LDFLAGS)
VulkanOpt: $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS)
g++ $(CFLAGS) -O3 -o VulkanOpt $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS) $(LDFLAGS)
.PHONY: test clean
run: VulkanRun
LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib
VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/vulkan/explicit_layer.d
./VulkanRun
test: Unit_Test
LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib
VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/vulkan/explicit_layer.d
./Unit_Test
debug: VulkanDebug
LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib
VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/vulkan/explicit_layer.d
optimise: VulkanOpt
LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib
VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/vulkan/explicit_layer.d
./VulkanOpt
7 clean:
rm -f VulkanRun
rm -f Unit_Test
rm -f VulkanDebug
rm -f VulkanOpt
I installed cmake using the latest install script for 3.21.0.
I created a CMakeLists.txt in the root of the project as follows :
cmake_minimum_required(VERSION 3.21.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
project(LanderSim)
file(GLOB_RECURSE SOURCES "src/**.cpp")
add_executable(main ${SOURCES})
find_package(Bullet CONFIG REQUIRED)
if (BULLET_FOUND)
include_directories(${BULLET_INCLUDE_DIRS})
target_link_libraries(main PRIVATE LinearMath Bullet3Common BulletDynamics BulletSoftBody)
endif (BULLET_FOUND)
After many hours of trying I decided to try vcpkg. Following the install instructions from bullet :
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install bullet3
This resulted in errors of
CMake Error at CMakeLists.txt:11 (find_package):
Could not find a package configuration file provided by "Bullet" with any
of the following names: BulletConfig.cmake bullet-config.cmake
Looking in CMakeCache.txt i see "Bullet_DIR:PATH=Bullet_DIR-NOTFOUND"
I found the BulletConfig.make file in "/home/ash/vcpkg/installed/x64-linux/share/bullet3" and in "/home/ash/vcpkg/packages/bullet3_x64-linux/share/bullet3" and set the MakeCache.txt var Bullet_DIR:PATH to these variables (tested one at a time).
Running again I get CMake set_and_check() function not recognised. Or something to that effect. Looking in the BulletConfig.make file I see these set_and_check() functions aren't recognised by the linter. I cant find any information about them being deprecated online but I assume this is the case. So I change to set() and CMake then succeeds and builds its files.
Running make I then get an error.
fatal error: btBulletDynamicsCommon.h: No such file or directory,
#include <btBulletDynamicsCommon.h>
I tried prepending bullet/ to the include path as others had this issue but it causes the same error.
So I must be doing something wrong and I'm obviously not understanding the process that CMake uses to add includes and link libraries. I'm sure, given the popularity of CMake, that there must be something obvious. But I've spent about 10 hours over a few days searching and trying different variations and I'm starting to get very frustrated.
I've bounced off CMake before (hence why I was working with a makefile for months), but I'm determined to do this properly. I just could really use some help if anyone knows how to get CMake to generate a makefile that can see a package installed with vcpkg.
Or indeed if the vcpkg of Bullet is out of date, then a way to link and include it with CMake alone would be great. I just thought vcpkg would be easier as it provides a cleaner file structure by default as well as a CMake config file.
Thanks.
EDIT1
I've used 'cmake .' and 'cmake . -DCMAKE_TOOLCHAIN_FILE=/home/ash/vcpkg/scripts/buildsystems/vcpkg.cmake' to build the makefile. Both result in the same missing headers errors when calling make.
EDIT2
All CMake files were removed from the project (except CMakeLists.txt) before each call to cmake to ensure no values were stored there.
EDIT3
Poked around a bit more. Here is the BulletConfig.cmake file :
#
# BulletConfig.cmake(.in)
#
# Use the following variables to compile and link against Bullet:
# BULLET_FOUND - True if Bullet was found on your system
# BULLET_USE_FILE - The file making Bullet usable
# BULLET_DEFINITIONS - Definitions needed to build with Bullet
# BULLET_INCLUDE_DIR - Directory where Bullet-C-Api.h can be found
# BULLET_INCLUDE_DIRS - List of directories of Bullet and it's dependencies
# BULLET_LIBRARIES - List of libraries to link against Bullet library
# BULLET_LIBRARY_DIRS - List of directories containing Bullet' libraries
# BULLET_ROOT_DIR - The base directory of Bullet
# BULLET_VERSION_STRING - A human-readable string containing the version
set(PACKAGE_PREFIX_DIR /home/ash/installed/x64-linux)
set ( BULLET_FOUND 1 )
set ( BULLET_USE_FILE "${PACKAGE_PREFIX_DIR}/share/bullet3/UseBullet.cmake" )
set ( BULLET_DEFINITIONS "" )
set ( BULLET_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include/bullet" )
set ( BULLET_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/bullet" )
set ( BULLET_LIBRARIES "LinearMath;Bullet3Common;BulletInverseDynamics;BulletCollision;BulletDynamics;BulletSoftBody" )
set ( BULLET_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib" )
set ( BULLET_ROOT_DIR "${PACKAGE_PREFIX_DIR}" )
set ( BULLET_VERSION_STRING "3.17" )
# Load targets
if(NOT TARGET Bullet3Common)
file(GLOB CONFIG_FILES "${PACKAGE_PREFIX_DIR}/share/bullet3/*Targets.cmake")
foreach(f ${CONFIG_FILES})
include(${f})
endforeach()
set(_DIR)
endif()
As stated before a few of the set functions were set_and_check(). So I changed to set() as apparently cmake 3.21 has no set_and_check() function. After a little testing by printing message(), i found that PACKAGE_PREFIX_DIR was not being set anywhere. So that is why I've set it explicitly in this file. The variables are now set correctly as reported by message() in the CMakeLists.txt file. But still it make cannot find the header files.
EDIT4
I created an empty project and ran through each library I wanted to include. Everything works except for Bullet3. However it does now see the header files. What changed between the two CMakeFiles? Nothing as far as I can tell. I'll need to find out because I have to port this project over but in the meantime this is another issue with the package.
from /home/ash/projects/C++/CMakeImportTests/src/main.cpp:22:
/home/ash/vcpkg/installed/x64-linux/include/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h:77:10:
fatal error: LinearMath/btVector3.h: No such file or directory
77 | #include "LinearMath/btVector3.h"
I think this is the same issue as described #7877
If i remove all includes of Bullet but leave the CMakeList.txt untouched, we get this error:
[ 50%] Building CXX object CMakeFiles/main.dir/src/main.cpp.o
[100%] Linking CXX executable main
/usr/bin/ld: cannot find -lLinearMath
/usr/bin/ld: cannot find -lBullet3Common
/usr/bin/ld: cannot find -lBulletDynamics
/usr/bin/ld: cannot find -lBulletSoftBody
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/main.dir/build.make:104: main] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/main.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Is this a clue that some environment variable is not set?
EDIT5
There seems to be an ordering dependency for the target_link_library call. The suggested usage is:
target_link_libraries(main PRIVATE LinearMath Bullet3Common BulletDynamics BulletSoftBody)
Checking bullet.pc in the libs/ directory i found
Libs: -L${libdir} -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath
So I tried rearranging and following the pattern:
target_link_libraries(main PRIVATE BulletSoftBody BulletDynamics BulletCollision Bullet3Common LinearMath)
Additionally there was also a need to manually link directories.
target_link_directories(main PRIVATE ${BULLET_LIBRARY_DIRS})
This now compiles without error in my test project. It seems LinearMath must be after most of the other libraries (although it can be before Bullet3Common it seems).
For some reason it's still not finding the header files when I copy the exact same CMake commands over to my main project. So I'm not free of this yet.
I should say that I was able to remove the change I made to BulletConfig.cmake of setting PACKAGE_PREFIX_DIR statically.
So just to recap my issue. A small test project works and I can use bullet and number of other libraries that I use in my main project. But if i copy this working CMakeLists.txt to my main project it can no longer find the headers and throws this error :
btBulletDynamicsCommon.h: No such file or directory
8 | #include <btBulletDynamicsCommon.h>
Bullet_DIR:PATH=/home/ash/vcpkg/installed/x64-linux/share/bullet3 is the same in both cases.
After all that.
The set_and_include() error is a known issue and mathisloge over at vcpkg git said the Bullet package needs to be updated. The workaround is to change the calls to set().
The ordering of the target libraries is important. The suggested way in the Bullet vcpkg package is :
target_link_libraries(main PRIVATE LinearMath Bullet3Common BulletDynamics BulletSoftBody)
But this fails to compile. It should be:
target_link_libraries(main PRIVATE BulletSoftBody BulletDynamics BulletCollision Bullet3Common LinearMath)
Also had to tell cmake the link directories using :
target_link_directories(main PRIVATE ${BULLET_LIBRARY_DIRS})
Then I still had header missing errors. But after a restart things just started working again. Hopefully there is enough here to help someone if they hit similar problems.

GHDL, Precompile Vendor Primitives and Cocotb

I have a design where I use an IP module generated by Lattice Diamond. This uses the Macxo3l library which is shipped with diamond as a vendor library.
Using GHDL I can compile the design including this library using the instructions from https://ghdl.readthedocs.io/en/latest/building/PrecompileVendorPrimitives.html then the commands.
ghdl -i --ieee=synopsys -P=lattice/ --workdir=work cores/*.vhd
ghdl -i --workdir=work src/*.vhd
However I have been unable to make this compile using cocotb. Below is my make file. Where I use the command VHDL_SOURCES_Lib which I found reference to at https://cocotb.readthedocs.io/en/latest/building.html
TOPLEVEL_LANG ?= vhdl
PWD=$(shell pwd)
ifeq ($(OS),Msys)
WPWD=$(shell sh -c 'pwd -W')
PYTHONPATH := $(WPWD)/../model;$(PYTHONPATH)
else
WPWD=$(shell pwd)
PYTHONPATH := $(WPWD)/../model:$(PYTHONPATH)
endif
VHDL_SOURCES_Lib = $(WPWD)/../lattice/
VHDL_SOURCES = $(WPWD)/../cores/Adder.vhd $(WPWD)/../cores/Counter.vhd $(WPWD)/../cores/Multiplyer.vhd $(WPWD)/../cores/SinCos.vhd $(WPWD)/../src/top.vhd
TOPLEVEL := top
MODULE := test_of_top
include $(shell cocotb-config --makefiles)/Makefile.inc
include $(shell cocotb-config --makefiles)/Makefile.sim
Compiling this however gives me the error:
make results.xml
make[1]: Entering directory '/HDL/cocotbTest'
make[1]: *** No rule to make target '/HDL/cocotbTest/../cores/Adder.vhd', needed by 'analyse'. Stop.
make[1]: Leaving directory '/HDL/cocotbTest'
/home/anaconda3/lib/python3.6/site-packages/cocotb/share/makefiles/Makefile.sim:84: recipe for target 'sim' failed
make: *** [sim] Error 2
I am able to run the cocotb examples using GHDL. How should I instruct cocotb to include the Vendor Primitive files.
Thank you for any help you can provide.
I think you should add the exact filenames in VHDL_SOURCES_Lib as documentation said :
VHDL_SOURCES_lib
A list of the VHDL source files to include in the VHDL library lib (currently GHDL only).
But to add precompiled library as you show, you have to pass a compile option to ghdl : -P=lattice/
Use COMPILE_ARGS to add it:
COMPILE_ARGS=-P=lattice/

Read Nifti image with ITK in C++

I am sorry if the question is primitive, but I can't figure the problem. I want to read nifti image in C++ using ITK libraries. I have used the code on Github: https://gist.github.com/rafamanzo/a3c258f4f74e898e9418. It is very simple code to read an image. Then I configured ITK into my project using CMake. The following is my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8)
project(MyProject)
set(CMAKE_INSTALL_PREFIX "/home/itk")
set(ITK_DIR "/home/itk/InsightToolkit-4.13.0/bin/")
set(VTK_DIR "/home/vtk/VTK-8.1.0/bin/")
find_package(ITK REQUIRED)
find_package(VTK REQUIRED)
if (ITKVtkGlue_LOADED)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
else()
find_package(ItkVtkGlue REQUIRED)
include(${ItkVtkGlue_USE_FILE})
set(Glue ItkVtkGlue)
endif()
include(${ITK_USE_FILE})
include(${VTK_USE_FILE})
add_executable(MyProject mainFile.cxx)
target_link_libraries(MyProject ${ITK_LIBRARIES})
"cmake .." is ran successfully.
But "make all" gives me an error:
make[2]: *** No rule to make target '/home/vtk/VTK-8.1.0/bin/lib/libvtkRenderingOpenGL2.so', needed by 'MyProject'. Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/MyProject.dir/all' failed
make[1]: *** [CMakeFiles/MyProject.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
And surprisingly, when I build the project from Eclipse, I got another error:
./bin/CMakeFiles/feature_tests.o: In function `main':
/home/MyProject/Debug/../bin/CMakeFiles/feature_tests.c:34: multiple definition of `main'
makefile:32: recipe for target 'MyProject' failed
./bin/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.o:/home/MyProject/Debug/../bin/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.c:540: first defined here
/usr/bin/ld: cannot find -l/home/vtk/VTK-8.1.0/bin/lib/libvtkRenderingContextOpenGL2-8.1.so
collect2: error: ld returned 1 exit status
make: *** [MyProject] Error 1
I am pretty sure that configuring ITK is easy, especially I have done it before, but to use ImageFileReader only. Any help is much appreciated. Thank you.
Just to read an image you don't need VTKGlue part of ITK nor VTK itself. And the reported problem comes from VTK. If you want to keep VTK (to be used for something else?), you should fix it. Maybe you need to set VTK_RENDERING_BACKEND to OpenGL2 or something similar. Try building some VTK examples using your VTK to see if those examples build and run. That might point you more precisely to the problem.

Is it possible to compile NASA Parallel Benchmarks (NPB) files in Linux using gfortran and openmpi?

I am attempting to run NPB benchmarking on my RHEL7.3 install but come into a similar issue as the question asked here
Error while building NAS benchmarks
Trying to make the BT benchmark, which is in fortran, I get the following error:
cd BT; make NPROCS=16 CLASS=W SUBTYPE= VERSION=
make[1]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
make[2]: Entering directory '/mnt/npb_install/NPB3.3-MPI/sys'
make[2]: Nothing to be done for 'all'
make[2]: Leaving directory '/mnt/npb_install/NPB3.3-MPI/sys'
../sys/setparams bt 16 W
make[2]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
make[3]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
gfortran -O -o ../bin/bt.W.16 bt.o make_set.o initialize.o exact_solution.o exact_rhs.o set_constants.o adi.o define.o copy_faces.o rhs.o solve_subs.o x_solve.o y_solve.o z_solve.o add.o error.o verifiy.o setup_mpi.o ../common/print_results.o ../common/timers.o btio.o -L/usr/lib/openmpi-x84_64/ -lmpi
/bin/ld: cannot find -lmpi
collect2: error: ld returned 1 exit status
make[3]: *** [bt-bt] Error 1
make[3]: Leaving direc.......
However I am not using Intel MPI but rather OpenMPI, though I don't full understand the implication of that.
My make.def file has the following mpi related settings
#-------------------------------------
# This is the fortran compiler usedd for MPI programs
#-----------------------------------------
MPIF77 = gfortran
# This links MPI fortran programs; usually the same as ${MPIF77}
FLINK = ${MPIF77}
#------------------------------------------
# These macros are passed to the linker to help link with MPI correctly
#-------------------------------------------
FMPI_LIB = -L/usr/lib/openmpi/lib/ -lmpi
#-----------------------------------------
# These macros are passed to the compiler to help find 'mpif.h'
#------------------------------------------
FMPI_INC = -I/usr/include/openmpi-x86_64/
Similar to those posted in the above question.
From the error, I assume that the input parameters -lmpi is not a valid input parameter for gfortran when compiling but removing it leads to a screen full of undefined references like:
file.f:(.text+0x123): undefined reference to 'mpi_whatever_'
Is it possible to compile NPB with gfortran? Or am I clearly doing something wrong here?
I have seen that using ifort is another option but I thought I'd ask the question before moving towards that possible solution
After hacking at it I resolved the issue with the following fixes, not sure what did it.
OpenMPI may have not been installed properly (was unable to call mpicc or other wrappers/comps), to fix it I ran the following commands
module avail
#displayed the openmpi-x86_64 module
module add open-x86_64
which mpirun
#displayed location of mpirun
The more likely fix was simply changing gfortran in the make.def file to mpif77

Resources