# Problems linking on Linux

**URL:** https://discourse.cmake.org/t/problems-linking-on-linux/12922
**Category:** Usage
**Created:** [November 9, 2024, 8:00am UTC](https://discourse.cmake.org/t/problems-linking-on-linux/12922 "2024-11-09T08:00:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)
#### Post date: [November 9, 2024, 8:00am UTC](https://discourse.cmake.org/t/problems-linking-on-linux/12922/1 "2024-11-09T08:00:03Z")

</div>

I’m not very experienced at Linux development, so please be kind 🙂

I’m trying to link with libtiff.a (static library) which is in /usr/local/lib

I have this in my CMakeLists.txt:

```auto
# Link with other targets.
target_link_libraries(DeepSkyStacker PRIVATE
    Qt6::Core
    Qt6::Widgets
    Qt6::Network
	DeepSkyStackerKernel
    libraw
    ZClass
)
if(WIN32)
target_link_libraries(DeepSkyStacker PRIVATE
    libtiff
)
endif()

if(WIN32)
set(DEBUG_DEPENDENCIES exiv2d zlibstaticd)
set(RELEASE_DEPENDENCIES exiv2 zlibstatic)
else()
set(DEBUG_DEPENDENCIES libtiff.a exiv2 expat libz.a)
set(RELEASE_DEPENDENCIES libtiff.a exiv2 expat libz.a)
endif()

set(ADDITIONAL_LIBRARY_DEPENDENCIES
    "$<$<CONFIG:Debug>:${DEBUG_DEPENDENCIES}>"
    "$<$<CONFIG:Release>:${RELEASE_DEPENDENCIES}>"
    "cfitsio"
)

if(WIN32)
set(ADDITIONAL_LIBRARY_DEPENDENCIES ${ADDITIONAL_LIBRARY_DEPENDENCIES}
    user32
    psapi
    htmlhelp
)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}")

```

when I try to link I get:

```auto
[32/32] Linking CXX executable DeepSkyStacker/DeepSkyStacker
FAILED: DeepSkyStacker/DeepSkyStacker 
: && /usr/bin/c++ -g DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/DeepSkyStacker_autogen/mocs_compilation.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/About.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/ExplorerBar.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/processingcontrols.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/ProcessingDlg.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/ProcessingSettingsDlg.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/RGBTab.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/SavePicture.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/StarMaskDlg.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/AskRegistering.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/RegisterSettings.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/AlignmentParameters.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/CometStacking.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/IntermediateFiles.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/OutputTab.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/PostCalibration.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/RawDDPSettings.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/ResultParameters.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/StackingParameters.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/StackSettings.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/BackgroundOptions.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/BatchStacking.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/CheckAbove.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/DropFilesDlg.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/ImageProperties.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/picturelist.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/RecommendedSettings.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/RenameGroup.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/SaveEditChanges.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/StackingDlg.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/StackRecap.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/lowerdockwidget.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/BaseDialog.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/DeepSkyStacker.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/Delaunay.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/editstars.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/progressdlg.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/selectrect.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/toolbar.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/ __/Tools/imageview.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/__ /Tools/QElidedLabel.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/__/Tools/QLinearGradientCtrl.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/DeepSkyStacker_autogen/O3VI4VFR3H/qrc_translations.cpp.o DeepSkyStacker/CMakeFiles/DeepSkyStacker.dir/DeepSkyStacker_autogen/EWIEGA46WW/qrc_resources.cpp.o -o DeepSkyStacker/DeepSkyStacker -Wl,-rpath,/opt/Qt/6.8.0/gcc_64/lib: DeepSkyStackerKernel/libDeepSkyStackerKernel.a LibRaw/buildfiles/liblibraw.a ZClass/libZClass.a -Wl,-Bstatic -ltiff -Wl,-Bdynamic -lexiv2 -lexpat -Wl,-Bstatic -lz -Wl,-Bdynamic -lcfitsio /opt/Qt/6.8.0/gcc_64/lib/libQt6Widgets.so.6.8.0 /opt/Qt/6.8.0/gcc_64/lib/libQt6Gui.so.6.8.0 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /opt/Qt/6.8.0/gcc_64/lib/libQt6Network.so.6.8.0 /opt/Qt/6.8.0/gcc_64/lib/libQt6Core.so.6.8.0 -llibtiff -Wl,-rpath-link,/opt/Qt/6.8.0/gcc_64/lib && :
/usr/bin/ld: cannot find -llibtiff: No such file or directory
/usr/bin/ld: note to link with /usr/local/lib/libtiff.a use -l:libtiff.a or rename it to liblibtiff.a
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

```

I imagine I’ve made a classic beginner’s mistake, but what is it please?

Thanks  
David

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [November 10, 2024, 2:44am UTC](https://discourse.cmake.org/t/problems-linking-on-linux/12922/2 "2024-11-10T02:44:29Z")

</div>

It looks like you’re building [GitHub - deepskystacker/DSS: DeepSkyStacker](https://github.com/deepskystacker/DSS/)  
This project uses some unconventional techniques in their CMakeLists files.  
I would try adding to the top level CMakeLists.txt like

```cmake
add_subdirectory(LibTiff)

```

before the line 116 `add_subdirectory(DeepSkyStacker)`

But to use system libtifff, add

```cmake
find_library(libtiff NAMES tiff REQUIRED)

```

In general in CMake projects one might use [https://cmake.org/cmake/help/latest/module/FindTIFF.html](https://cmake.org/cmake/help/latest/module/FindTIFF.html)

---

<div class="post-metadata">

### Author: ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)
#### Post date: [November 10, 2024, 6:56am UTC](https://discourse.cmake.org/t/problems-linking-on-linux/12922/3 "2024-11-10T06:56:37Z")

</div>

As I’m new to CMake it is quite likely that I’m not aware of “best practice”. Yes, I wrote all the CMakeLists.txt files you see in that GitHub project.

The linux branch is the one I am working on - CMake is a very recent thing for us.

I attach the latest CMakeLists.txt

Any suggestions for improvement most welcome - though I’m not clear what that find\_library call buys me.  
[CMakeLists.txt](https://discourse.cmake.org/uploads/short-url/z8ODz0WPM0xY9oCYxQUmcNsGnIG.txt) (13.3 KB)

---

<div class="post-metadata">

### Author: ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)
#### Post date: [November 10, 2024, 6:57am UTC](https://discourse.cmake.org/t/problems-linking-on-linux/12922/4 "2024-11-10T06:57:31Z")

</div>

And here’s the top-level CMakeLists.txt  
[CMakeLists.txt](https://discourse.cmake.org/uploads/short-url/wXO1X6THNgDpEjFNXBXOKMwgpps.txt) (4.7 KB)

---

<div class="post-metadata">

### Author: ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)
#### Post date: [November 10, 2024, 6:59am UTC](https://discourse.cmake.org/t/problems-linking-on-linux/12922/5 "2024-11-10T06:59:37Z")

</div>

Here’s what the configure output looks like:

```auto
1> CMake generation started for configuration: 'Qt-Debug-Linux'.
1> Found cmake executable at /usr/bin/cmake.
1> /usr/bin/cmake -G "Ninja" -DCMAKE_PREFIX_PATH:STRING="/opt/Qt/6.8.0/gcc_64" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_SYSTEM_NAME:STRING="Linux" /home/amonra/.vs/DSS/CMakeLists.txt;
1> [CMake] WIN32 is set to , LINUX is set to 1
1> [CMake] System Name is: Linux, prefix path: /opt/Qt/6.8.0/gcc_64
1> [CMake] x64 architecture in use
1> [CMake] CMAKE_SOURCE_DIR: /home/amonra/.vs/DSS
1> [CMake] CMAKE_VS_PLATFORM_NAME: x64
1> [CMake] CMAKE_BUILD_TYPE: Debug
1> [CMake] CMAKE_INSTALL_PREFIX set to: /home/amonra/.vs/DSS/Linux/x64/Debug
1> [CMake] -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
1> [CMake] -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
1> [CMake] Configuring project: DeepSkyStacker
1> [CMake] -- Link libraries: Qt6::CoreQt6::CoreQt6::WidgetsQt6::NetworkDeepSkyStackerKernellibrawZClass$<$<CONFIG:Debug>:tiff.aexiv2.aexpat.az.acfitsio.a>$<$<CONFIG:Release>:tiff.aexiv2.aexpat.az.acfitsio.a>
1> [CMake] Qt Deploy Bin Dir: .
1> [CMake] Qt Deploy Lib Dir: .
1> [CMake] Target filename:$<TARGET_FILE_NAME:DeepSkyStacker>
1> [CMake] executable_path: ./$<TARGET_FILE_NAME:DeepSkyStacker>
1> [CMake] deploy tools options arg: .

```

---

<div class="post-metadata">

### Author: ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)
#### Post date: [November 10, 2024, 9:12am UTC](https://discourse.cmake.org/t/problems-linking-on-linux/12922/6 "2024-11-10T09:12:59Z")

</div>

ARRGGH!

The problem came from the CMakeLists.txt for one of the static libs which contained:

target\_link\_libraries(${PROJECT\_NAME} PUBLIC libraw libtiff ZClass )

David
