Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6863789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:49:47+00:00 2026-05-27T02:49:47+00:00

I have a problem with the usage of CMake on Linux 64 bit. I

  • 0

I have a problem with the usage of CMake on Linux 64 bit. I have a sample in C that must link to a library (xr_arp.a) which has a link dependency on another lib (libcrypto.a). The following makefile that I did to build my sample code is linking successfully:

CFLAGS = -I../Common -I../xr -I../../../openssl/include
LIBS = ../xr/xr_arp.a ../../../openssl/lib/libcrypto.a
TARGET = sample
OBJFILES = sample.o 

all: $(TARGET)

$(TARGET): Makefile $(OBJFILES)
    $(CC) -o $@ $(OBJFILES) $(LIBS)

clean:
    rm -rf *.o $(TARGET)

.SUFFIXES: .c .o

.c.o:
    $(CC) -Wall $(CFLAGS) -c $<

However, I would like to convert this makefile to use CMake instead. When I use the following CMakeLists.txt file, I get that xr_arp.c has undefined reference to `SHA1′ as it seems like it cannot link xr_arp.a to libcrypto.a:

cmake_minimum_required(VERSION 2.8)
project (SAMPLE C)

set(CMAKE_C_FLAGS "-Wall")

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/../Common
    ${CMAKE_CURRENT_SOURCE_DIR}/../xr
)

add_executable(
    sample
    sample.c
)

target_link_libraries(
    sample
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../openssl/lib/libcrypto.a
    ${CMAKE_CURRENT_SOURCE_DIR}/../xr/xr_arp.a
)

Can someone point me out on what is the difference between those two files? Why is it working with the makefile and it isn’t with CMake? Is there any procedure I could use to force the linking between xr_arp.a and libcrypto.a? Please take note that both libs are third-party and are not mine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:49:48+00:00Added an answer on May 27, 2026 at 2:49 am

    Have you tried switching the order the libraries are specified in TARGET_LINK_LIBRARIES? In many cases it shouldn’t make a difference, but I’ve run into cases with certain linkers where it does. I believe the GNU linker on Linux is one case where it makes a difference.

    I think that xr_arp.a should appear first, so that the linker knows to look for SHA1 in the libraries that follow it.

    Failing that, try running “make VERBOSE=1” and comparing the linker command that is generated by CMake with the one generated by the Makefile.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have similar problem to one discussed here , but with stronger practical usage.
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with fancybox. I want to write a function that will run
I have a problem with a C++ application I've developed which uses dlopen to
i have this problem: I have created a bash script that performs some tasks.
I have a slight problem with usage of jquery validation plugin. It works perfectly
I have a problem with an application I'm debugging. Steady state memory usage is
i have following problem: I have a class Foo which encapsulates a web-api. the
I have problem on deleting component which is created on runtime. Please help me.
I have a problem with an app that takes an XML feed, parses it,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.