Failing to Build Basic Plugin Demo

Hello,

I am trying to build the DemoPlugin app that is on the ImFusion GitHub page. I successfully use CMake to generate a VisualStudio project file but when I build the project I get a linker error saying that the ImFusionLib could not be opened. I am building on Windows 10 Pro with msvc2019_64. Thanks in advance for your help!

Here is my CMakeFile:

# Define a new CMake project for the demo plugin
project(DemoPlugin)
cmake_minimum_required(VERSION 3.5.0)
set(CMAKE_CXX_STANDARD 17)

list(APPEND CMAKE_PREFIX_PATH "C:\\Program Files\\ImFusion\\ImFusion Suite")

# Locate the ImFusion SDK.
# List required modules/plugins in the COMPONENTS section (e.g. COMPONENTS ImFusionSeg ImFusionReg).
find_package(ImFusionLib REQUIRED COMPONENTS ImFusionLib)

# Enable automatic MOC, RCC and UIC preprocessing for Qt
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)


# Define and configure the CMake target
set(Sources
    DemoAlgorithm.cpp
    DemoController.cpp
    DemoFactory.cpp
    DemoPlugin.cpp
)
set(Headers
	DemoAlgorithm.h
	DemoController.h
	DemoFactory.h
	DemoPlugin.h
)
set(UiSources
	DemoController.ui
)

# Define target library
add_library(DemoPlugin SHARED ${Sources} ${UiHeaders} ${Headers})
target_include_directories(DemoPlugin PRIVATE
	"C:\\Program Files\\ImFusion\\ImFusion Suite\\include" "C:\\Program Files\\ImFusion\\ImFusion Suite\\include\\ImFusion\\Ext" "C:\\Qt\\5.15.8\\msvc2019_64\\include"
)
# Link against the ImFusionLib and selected modules/plugins
target_link_libraries(DemoPlugin PRIVATE
	ImFusionLib
)

# Define output target directories and provide instructions on how to launch
# the ImFusion Suite with the built custom plugin.
# These functions are provided by the ImFusionLib target config. 
imfusion_set_common_target_properties()
imfusion_provide_ide_instructions()

Hi Joshua and welcome to our Forum!
It is hard for me to say exactly what the problem might be given this information but your CMakeLists.txt looks correct to me. Are you getting any warnings when generating the build files? Please check that the paths you have in your cmake are correct and that the ImFusionLib_DIR CMake-Variable is set correctly. Please set it to <imfusionlib_installation_dir>/cmake (if the paths in your CMakeLists.txt are correct it should be C:\Program Files\ImFusion\ImFusion Suite\cmake). Could you share with me your build log?
Best Regards,
Federico

Hello Federico,
Thanks for your help! I’ve attached the log from making the build files below and I’ve attached the build logs as an image. I don’t see any errors in generating the make file and the only error I see when building the plugin is that it cannot find ImFusionLib. There are two warnings saying that AlgorithmFactory must have a module name and registerAlgorithm must have a unique ID and GUI name.

Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.17763.
Created VS user file D:/Documents/USReg/ImFusion Examples/ExamplePlugin/out/build/DemoPlugin.vcxproj.user

TODO: To launch the ImFusion SDK with your DemoPlugin plugin, set the
IMFUSION_PLUGIN_PATH environment variable to your build output directory
(i.e. ‘D:/Documents/USReg/ImFusion Examples/ExamplePlugin/out/build/bin/(Debug|Release)’)
and then launch C:/Program Files/ImFusion/ImFusion Suite/SuiteDev/ImFusionSuite.exe.
INFO: The Visual Studio project created by CMake is already configured correctly.

Configuring done
Generating done

Hi Joshua,
a colleague tells me that you might have installed a version of the ImFusionLib which uses CMake namespaces for its targets. Concretely, this means you have to call target_link_libraries(DemoPlugin PRIVATE ImFusion::ImFusionLib).
Hopefully this fixes your issue.
Best Regards

Hello Federico,

That worked! Thanks so much Federico! I am so appreciative of your time and help. I had noticed that the Visual Studio Linker Input (which was in the Configuration Properties page) was not specifying the directory of the ImFusionLib library correctly and when I added the full directory to the ImFusionLib, the error went away but many errors related to linking Qt popped up. Your suggestion fixed all of these issues. Thanks so much!

1 Like