Re: [CMake] undefined reference to `_exit'

2019-02-04 Thread hex

dear community,

This question has originally been placed in another community [1].
I did read the mailing list netiquette before posting here but I was not 
aware this behaviour is discouraged.
Therefore, I want to apologize. Good etiquette is important, I am 
grateful for any advice on how I can make the Internet a better place.


The solution to the undefined reference errors is to set the

-specs=nosys.specs flag as mentioned here [2]
in combination with not using the -nostartfiles flag which made the 
_exit referenced in nosys.specs not being used.


Since this is also making this question a duplicate of [2] I decided to 
delete it in stackoverflow.


Thank you for your help.


[1] 
https://stackoverflow.com/questions/54487747/cmake-undefined-reference-to-exit-while-including-startup-code-as-a-library
[2] 
https://stackoverflow.com/questions/19419782/exit-c-text0x18-undefined-reference-to-exit-when-using-arm-none-eabi-gcc



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] undefined reference to `_exit'

2019-02-01 Thread frodak17
If I follow you correctly you are trying to replace the startup files that
are normally used with your own versions.

You don't mention what the new library is that you are using to replace the
startup files.
The standard startup files provide _init and _fini.

You are also missing _exit which I thought would have been taken care of if
"-specs=nosys.specs" was being used.  It's not shown which specs option is
being used.

Any reason you aren't just using the standard startup files and follow the
retarget example to do any special initialization before main() is called?

On Fri, Feb 1, 2019 at 6:17 PM Kyle Edwards via CMake 
wrote:

> Hex,
>
> Can you see what else is in /opt/arm-none-eabi/lib/thumb/v7-ar/fpv3/hard
> (the same directory as libc.a)? There might be another system library that
> contains the _exit() implementation that isn't being linked due to your use
> of the -nostartfiles flag.
>
> Kyle
>
> On Fri, 2019-02-01 at 22:15 +, hex wrote:
>
> hello,
>
> I am trying to include a static library that contains the startup code for
> ARM processor to my  CMake project for cross compilation.
>
> I included the linker script and added it to the executable. Flags and
> include files are properly set in the CMake build output. The path to the
> library is also correctly seen.
>
> The linker fails on the startup code:
>
>
> Scanning dependencies of target testApp
> [ 50%] Building CXX object CMakeFiles/testApp.dir/src/main.c.obj
> [100%] Linking CXX executable testApp
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-exit.o):
>  In function `exit':
> exit.c:(.text.exit+0x1c): undefined reference to `_exit'
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-fini.o):
>  In function `__libc_fini_array':
> fini.c:(.text.__libc_fini_array+0x2c): undefined reference to `_fini'
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-init.o):
>  In function `__libc_init_array':
> init.c:(.text.__libc_init_array+0x38): undefined reference to `_init'
> collect2: error: ld returned 1 exit status
>
>
> Here is my CMakeLists file:
> *cmake_minimum_required(VERSION 3.5.1)**project 
> (hello-world)**set(SOURCE_FILES src/main.c)**set (LINKER_SCRIPT 
> linker_script.ld)**add_executable(${TARGET_NAME} 
> ${SOURCE_FILES})**set_target_properties( ${TARGET_NAME} PROPERTIES 
> LINK_DEPENDS ${LINKER_SCRIPT})**set(CMAKE_EXE_LINKER_FLAGS 
> "${CMAKE_EXE_LINKER_FLAGS} -Wl,-build-id=none -Wl,-T ${LINKER_SCRIPT} " CACHE 
> STRING "" FORCE )**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -march=armv7-a")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -mfpu=vfpv3")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -mfloat-abi=hard")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -Wall")**set(COMMON_FLAGS "${COMMON_FLAGS} -O0")**set(COMMON_FLAGS 
> "${COMMON_FLAGS} -nostartfiles")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -fmessage-length=0")**set(COMMON_FLAGS "${COMMON_FLAGS} 
> -fno-exceptions")**set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} 
> ${COMMON_FLAGS}")**set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} 
> ${COMMON_FLAGS}")**include_directories( inc )**find_library(LIB_C NAMES libc 
> PATHS "lib" )**target_link_libraries(${TARGET_NAME} ${LIB_C})*
>
> How can I solve this problem? The only dependency here is the library 
> itself...
>
> Thank you in advance for any response.
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to 
> subscribe/unsubscribe:https://cmake.org/mailman/listinfo/cmake
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake 

Re: [CMake] undefined reference to `_exit'

2019-02-01 Thread Kyle Edwards via CMake
Hex,
Can you see what else is in /opt/arm-none-eabi/lib/thumb/v7-
ar/fpv3/hard (the same directory as libc.a)? There might be another
system library that contains the _exit() implementation that isn't
being linked due to your use of the -nostartfiles flag.
Kyle
On Fri, 2019-02-01 at 22:15 +, hex wrote:
> hello, 
> I am trying to include a static library that contains the startup
> code for ARM processor to my  CMake project for cross compilation. 
> I included the linker script and added it to the executable. Flags
> and include files are properly set in the CMake build output. The
> path to the library is also correctly seen. 
> The linker fails on the startup code:
> 
> Scanning dependencies of target testApp
> [ 50%] Building CXX object CMakeFiles/testApp.dir/src/main.c.obj
> [100%] Linking CXX executable testApp
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-
> eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-
> ar/fpv3/hard/libc.a(lib_a-exit.o): In function `exit':
> exit.c:(.text.exit+0x1c): undefined reference to `_exit'
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-
> eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-
> ar/fpv3/hard/libc.a(lib_a-fini.o): In function `__libc_fini_array':
> fini.c:(.text.__libc_fini_array+0x2c): undefined reference to `_fini'
> /opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-
> eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-
> ar/fpv3/hard/libc.a(lib_a-init.o): In function `__libc_init_array':
> init.c:(.text.__libc_init_array+0x38): undefined reference to `_init'
> collect2: error: ld returned 1 exit status
> 
> 
> Here is my CMakeLists file:
> 
> cmake_minimum_required(VERSION 3.5.1)
> project (hello-world)
> 
> set(SOURCE_FILES src/main.c)
> 
> set (LINKER_SCRIPT linker_script.ld)
> 
> add_executable(${TARGET_NAME} ${SOURCE_FILES})
> 
> set_target_properties( ${TARGET_NAME} PROPERTIES LINK_DEPENDS
> ${LINKER_SCRIPT})
> 
> set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-build-
> id=none -Wl,-T ${LINKER_SCRIPT} " CACHE STRING "" FORCE )
> 
> set(COMMON_FLAGS "${COMMON_FLAGS} -march=armv7-a")
> set(COMMON_FLAGS "${COMMON_FLAGS} -mfpu=vfpv3")
> set(COMMON_FLAGS "${COMMON_FLAGS} -mfloat-abi=hard")
> set(COMMON_FLAGS "${COMMON_FLAGS} -Wall")
> set(COMMON_FLAGS "${COMMON_FLAGS} -O0")
> set(COMMON_FLAGS "${COMMON_FLAGS} -nostartfiles")
> set(COMMON_FLAGS "${COMMON_FLAGS} -fmessage-length=0")
> set(COMMON_FLAGS "${COMMON_FLAGS} -fno-exceptions")
> set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
> 
> include_directories( inc )
> 
> find_library(LIB_C NAMES libc PATHS "lib" )
> 
> target_link_libraries(${TARGET_NAME} ${LIB_C})
> 
> 
> How can I solve this problem? The only dependency here is the library
> itself...
> 
> Thank you in advance for any response. 
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.
> cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For
> more information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at http://www.kitware.com/op
> ensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] undefined reference to 'pthread_create'

2016-02-04 Thread Rolf Eike Beer
Am Donnerstag, 4. Februar 2016, 10:53:37 schrieb rpela...@archlinux.info:
> I believe that doesn't have anything to do with C11 flags. You are just
> missing the link to the pthread library. I could be wrong.
> 
> Try and add this to your cmake file:
> find_package (Threads)

First:

> set(THREADS_PREFER_PTHREAD_FLAG TRUE)

Always set this if you don't need to be backwards compatible to some obscure 
old CMake code.

If you _need_ threads:

> find_package (Threads REQUIRED)

If it is not required, but optional, check THREADS_FOUND afterwards.

If you can require a CMake >= 3.1:

> target_link_libraries(mything Threads::Threads)

Eike

signature.asc
Description: This is a digitally signed message part.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] undefined reference to 'pthread_create'

2016-02-04 Thread rpela...@archlinux.info
I believe that doesn't have anything to do with C11 flags. You are just missing 
the link to the pthread library. I could be wrong.

Try and add this to your cmake file:
find_package (Threads) 
target_link_libraries (myexecutable/lib ${CMAKE_THREAD_LIBS_INIT})


Sent from my iPhone

> On Feb 4, 2016, at 10:42 AM, Aaron Boxer  wrote:
> 
> Hello,
> I have a cmake project that uses C++11 threads.
> I have added the lines 
> 
> set (CMAKE_CXX_STANDARD 14)
> set(CMAKE_CXX_STANDARD_REQUIRED ON)
> 
> 
> CMAKE version is 3.2.2, running on Ubuntu.
> 
> When I try to build, I get the error
> 
> undefined reference to `pthread_create`
> 
> Any ideas on how to fix this?
> 
> Thanks!
> Aaron
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] undefined reference to 'pthread_create'

2016-02-04 Thread J Decker
Probably didn't previously need pthreads until you updated to use
C++11 features which brings in pthreads in the deadstart code...


On Thu, Feb 4, 2016 at 8:53 AM, rpela...@archlinux.info
 wrote:
> I believe that doesn't have anything to do with C11 flags. You are just
> missing the link to the pthread library. I could be wrong.
>
> Try and add this to your cmake file:
>
> find_package (Threads)
>
> target_link_libraries (myexecutable/lib ${CMAKE_THREAD_LIBS_INIT})
>
>
>
> Sent from my iPhone
>
> On Feb 4, 2016, at 10:42 AM, Aaron Boxer  wrote:
>
> Hello,
> I have a cmake project that uses C++11 threads.
> I have added the lines
>
> set (CMAKE_CXX_STANDARD 14)
> set(CMAKE_CXX_STANDARD_REQUIRED ON)
>
>
> CMAKE version is 3.2.2, running on Ubuntu.
>
> When I try to build, I get the error
>
> undefined reference to `pthread_create`
>
> Any ideas on how to fix this?
>
> Thanks!
> Aaron
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] undefined reference to 'pthread_create'

2016-02-04 Thread Aaron Boxer
Thanks. So, even though threading is part of the standard, I still need to
link to pthreads library ?

On Thu, Feb 4, 2016 at 11:53 AM, rpela...@archlinux.info <
rpela...@archlinux.info> wrote:

> I believe that doesn't have anything to do with C11 flags. You are just
> missing the link to the pthread library. I could be wrong.
>
> Try and add this to your cmake file:
>
> find_package (Threads)
>
> target_link_libraries (myexecutable/lib ${CMAKE_THREAD_LIBS_INIT})
>
>
>
> Sent from my iPhone
>
> On Feb 4, 2016, at 10:42 AM, Aaron Boxer  wrote:
>
> Hello,
> I have a cmake project that uses C++11 threads.
> I have added the lines
>
> set (CMAKE_CXX_STANDARD 14)
> set(CMAKE_CXX_STANDARD_REQUIRED ON)
>
>
> CMAKE version is 3.2.2, running on Ubuntu.
>
> When I try to build, I get the error
>
> undefined reference to `pthread_create`
>
> Any ideas on how to fix this?
>
> Thanks!
> Aaron
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] undefined reference to 'pthread_create'

2016-02-04 Thread J Decker
On Thu, Feb 4, 2016 at 9:55 AM, Aaron Boxer  wrote:
> Thanks. So, even though threading is part of the standard, I still need to
> link to pthreads library ?

Yes; sounds more like an issue for GCC :)   I mean you don't have to
tell it to link against c library or c++ runtime libraries... and it
IS pthread specific so it's not like there's going to be some
alternative provider for such services.

using MinGW under linux to get a windows output it links automatically
to a 'winpthreads.dll' which then becomes a runtime requirement... so
it's not impossible for the compiler suite to do.


>
> On Thu, Feb 4, 2016 at 11:53 AM, rpela...@archlinux.info
>  wrote:
>>
>> I believe that doesn't have anything to do with C11 flags. You are just
>> missing the link to the pthread library. I could be wrong.
>>
>> Try and add this to your cmake file:
>>
>> find_package (Threads)
>>
>> target_link_libraries (myexecutable/lib ${CMAKE_THREAD_LIBS_INIT})
>>
>>
>>
>> Sent from my iPhone
>>
>> On Feb 4, 2016, at 10:42 AM, Aaron Boxer  wrote:
>>
>> Hello,
>> I have a cmake project that uses C++11 threads.
>> I have added the lines
>>
>> set (CMAKE_CXX_STANDARD 14)
>> set(CMAKE_CXX_STANDARD_REQUIRED ON)
>>
>>
>> CMAKE version is 3.2.2, running on Ubuntu.
>>
>> When I try to build, I get the error
>>
>> undefined reference to `pthread_create`
>>
>> Any ideas on how to fix this?
>>
>> Thanks!
>> Aaron
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] undefined reference to 'pthread_create'

2016-02-04 Thread Aaron Boxer
Thanks, guys This is working now.

Cheers,
Aaron

On Thu, Feb 4, 2016 at 1:05 PM, J Decker  wrote:

> On Thu, Feb 4, 2016 at 9:55 AM, Aaron Boxer  wrote:
> > Thanks. So, even though threading is part of the standard, I still need
> to
> > link to pthreads library ?
>
> Yes; sounds more like an issue for GCC :)   I mean you don't have to
> tell it to link against c library or c++ runtime libraries... and it
> IS pthread specific so it's not like there's going to be some
> alternative provider for such services.
>
> using MinGW under linux to get a windows output it links automatically
> to a 'winpthreads.dll' which then becomes a runtime requirement... so
> it's not impossible for the compiler suite to do.
>
>
> >
> > On Thu, Feb 4, 2016 at 11:53 AM, rpela...@archlinux.info
> >  wrote:
> >>
> >> I believe that doesn't have anything to do with C11 flags. You are just
> >> missing the link to the pthread library. I could be wrong.
> >>
> >> Try and add this to your cmake file:
> >>
> >> find_package (Threads)
> >>
> >> target_link_libraries (myexecutable/lib ${CMAKE_THREAD_LIBS_INIT})
> >>
> >>
> >>
> >> Sent from my iPhone
> >>
> >> On Feb 4, 2016, at 10:42 AM, Aaron Boxer  wrote:
> >>
> >> Hello,
> >> I have a cmake project that uses C++11 threads.
> >> I have added the lines
> >>
> >> set (CMAKE_CXX_STANDARD 14)
> >> set(CMAKE_CXX_STANDARD_REQUIRED ON)
> >>
> >>
> >> CMAKE version is 3.2.2, running on Ubuntu.
> >>
> >> When I try to build, I get the error
> >>
> >> undefined reference to `pthread_create`
> >>
> >> Any ideas on how to fix this?
> >>
> >> Thanks!
> >> Aaron
> >>
> >> --
> >>
> >> Powered by www.kitware.com
> >>
> >> Please keep messages on-topic and check the CMake FAQ at:
> >> http://www.cmake.org/Wiki/CMake_FAQ
> >>
> >> Kitware offers various services to support the CMake community. For more
> >> information on each offering, please visit:
> >>
> >> CMake Support: http://cmake.org/cmake/help/support.html
> >> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> >> CMake Training Courses: http://cmake.org/cmake/help/training.html
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://public.kitware.com/mailman/listinfo/cmake
> >
> >
> >
> > --
> >
> > Powered by www.kitware.com
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> > http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Kitware offers various services to support the CMake community. For more
> > information on each offering, please visit:
> >
> > CMake Support: http://cmake.org/cmake/help/support.html
> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
> > CMake Training Courses: http://cmake.org/cmake/help/training.html
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/cmake
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] undefined reference to error when use c extension

2015-06-05 Thread J Decker
Or make c++ wrappers that use dlopen/dlsym or loadlibrary/getprocaddress as
appropriate and reference the libs through an interface class.

On Fri, Jun 5, 2015 at 7:44 PM, J Decker d3c...@gmail.com wrote:

 it's not the lib, it's the header interface to the lib.

 On Fri, Jun 5, 2015 at 7:42 PM, Sunrise helios.cor...@gmail.com wrote:

  Thanks for your reply. I am aware of extern C {} but this is not an
 option for me. As I mentioned, there are a lot of lib files (which were not
 written by me) and I was wondering if lib itself could be untouched.


 On 06/05/2015 07:33 PM, J Decker wrote:

 c++ does name mangling on functions... so functions like 'f' become a
 much more complex name (as shown in the xxx not found in your error
 messages).
 In order for C++ to not produce a mangled name C functions have to be
 defined as

  extern c void f( void );
 but 'extern c' is not liked by C... so you really need to define in the
 shared header something like...

  #ifdef __cplusplus
 #define CEXTERN extern C
 #ese
 #define CEXTERN
 #endif

  CEXTERN void f( void );

  But of course since you don't know about name mangling I guess you
 don't know proper header usage either.  This is not a cmake issue, but a
 general C++ issue... and you'd do better asking stack exchange or something.

 On Fri, Jun 5, 2015 at 6:37 PM, Sunrise helios.cor...@gmail.com wrote:

  Hello,

 I am linking my code to a library. My code is in C++ but the library is
 in C.

 The problem is that whenever the extension of library implementations
 are c (not cpp), they are not linked and I get undefined reference to
 error.

 Here is an example:

 Suppose I have
 ./src/main.cpp   // as main file
 ./include/lib.h
 ./include/lib.c  // as a library

 And the cmake file is

 cmake_minimum_required(VERSION 2.8)
 project(myproj)

 set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 include_directories(${INCLUDE_DIR})
 add_library(MY_LIB ${INCLUDE_DIR}/Lib.c)

 set(EXECUTABLE_NAME myproj)
 set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
 add_executable(myproj ${SOURCE_DIR}/main.cpp)

 target_link_libraries(myproj MY_LIB)

 This returns undefined reference to error, but if I rename lib.c to
 lib.cpp, everything works fine.

 How can I resolve this? I do not want to rename the file to cpp,
 because there are a lot of library files and I prefer to keep the library
 implementations untouched.

 Thanks.

 --

 Powered by www.kitware.com

 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ

 Kitware offers various services to support the CMake community. For more
 information on each offering, please visit:

 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html

 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html

 Follow this link to subscribe/unsubscribe:
 http://public.kitware.com/mailman/listinfo/cmake





-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] undefined reference to error when use c extension

2015-06-05 Thread Sunrise
Thanks for your reply. I am aware of extern C {} but this is not an 
option for me. As I mentioned, there are a lot of lib files (which were 
not written by me) and I was wondering if lib itself could be untouched.


On 06/05/2015 07:33 PM, J Decker wrote:
c++ does name mangling on functions... so functions like 'f' become a 
much more complex name (as shown in the xxx not found in your error 
messages).
In order for C++ to not produce a mangled name C functions have to be 
defined as


extern c void f( void );
but 'extern c' is not liked by C... so you really need to define in 
the shared header something like...


#ifdef __cplusplus
#define CEXTERN extern C
#ese
#define CEXTERN
#endif

CEXTERN void f( void );

But of course since you don't know about name mangling I guess you 
don't know proper header usage either.  This is not a cmake issue, but 
a general C++ issue... and you'd do better asking stack exchange or 
something.


On Fri, Jun 5, 2015 at 6:37 PM, Sunrise helios.cor...@gmail.com 
mailto:helios.cor...@gmail.com wrote:


Hello,

I am linking my code to a library. My code is in C++ but the
library is in C.

The problem is that whenever the extension of library
implementations are c (not cpp), they are not linked and I get
undefined reference to error.

Here is an example:

Suppose I have
./src/main.cpp // as main file
./include/lib.h
./include/lib.c // as a library

And the cmake file is

cmake_minimum_required(VERSION 2.8)
project(myproj)

set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${INCLUDE_DIR})
add_library(MY_LIB ${INCLUDE_DIR}/Lib.c)

set(EXECUTABLE_NAME myproj)
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(myproj ${SOURCE_DIR}/main.cpp)

target_link_libraries(myproj MY_LIB)

This returns undefined reference to error, but if I rename lib.c
to lib.cpp, everything works fine.

How can I resolve this? I do not want to rename the file to cpp,
because there are a lot of library files and I prefer to keep the
library implementations untouched.

Thanks.

--

Powered by www.kitware.com http://www.kitware.com

Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community.
For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake




-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] undefined reference to error when use c extension

2015-06-05 Thread J Decker
c++ does name mangling on functions... so functions like 'f' become a much
more complex name (as shown in the xxx not found in your error messages).
In order for C++ to not produce a mangled name C functions have to be
defined as

extern c void f( void );
but 'extern c' is not liked by C... so you really need to define in the
shared header something like...

#ifdef __cplusplus
#define CEXTERN extern C
#ese
#define CEXTERN
#endif

CEXTERN void f( void );

But of course since you don't know about name mangling I guess you don't
know proper header usage either.  This is not a cmake issue, but a general
C++ issue... and you'd do better asking stack exchange or something.

On Fri, Jun 5, 2015 at 6:37 PM, Sunrise helios.cor...@gmail.com wrote:

  Hello,

 I am linking my code to a library. My code is in C++ but the library is in
 C.

 The problem is that whenever the extension of library implementations are 
 c (not cpp), they are not linked and I get undefined reference to
 error.

 Here is an example:

 Suppose I have
 ./src/main.cpp   // as main file
 ./include/lib.h
 ./include/lib.c  // as a library

 And the cmake file is

 cmake_minimum_required(VERSION 2.8)
 project(myproj)

 set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 include_directories(${INCLUDE_DIR})
 add_library(MY_LIB ${INCLUDE_DIR}/Lib.c)

 set(EXECUTABLE_NAME myproj)
 set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
 add_executable(myproj ${SOURCE_DIR}/main.cpp)

 target_link_libraries(myproj MY_LIB)

 This returns undefined reference to error, but if I rename lib.c to
 lib.cpp, everything works fine.

 How can I resolve this? I do not want to rename the file to cpp, because
 there are a lot of library files and I prefer to keep the library
 implementations untouched.

 Thanks.

 --

 Powered by www.kitware.com

 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ

 Kitware offers various services to support the CMake community. For more
 information on each offering, please visit:

 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html

 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html

 Follow this link to subscribe/unsubscribe:
 http://public.kitware.com/mailman/listinfo/cmake

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] undefined reference to error when use c extension

2015-06-05 Thread Greg Marr
If you are including the .h file for the .c file in your .cpp file and it 
doesn't already have extern C in it, wrapping it like this when including it 
in your cpp should help:

extern C
{
#include header.h
}



Sent from my Verizon Wireless 4G LTE smartphone


 Original message 
From: J Decker d3c...@gmail.com
Date: 06/05/2015 10:33 PM (GMT-05:00)
To: Sunrise helios.cor...@gmail.com
Cc: cmake@cmake.org
Subject: Re: [CMake] undefined reference to error when use c extension

c++ does name mangling on functions... so functions like 'f' become a much more 
complex name (as shown in the xxx not found in your error messages).
In order for C++ to not produce a mangled name C functions have to be defined as

extern c void f( void );
but 'extern c' is not liked by C... so you really need to define in the 
shared header something like...

#ifdef __cplusplus
#define CEXTERN extern C
#ese
#define CEXTERN
#endif

CEXTERN void f( void );

But of course since you don't know about name mangling I guess you don't know 
proper header usage either.  This is not a cmake issue, but a general C++ 
issue... and you'd do better asking stack exchange or something.

On Fri, Jun 5, 2015 at 6:37 PM, Sunrise 
helios.cor...@gmail.commailto:helios.cor...@gmail.com wrote:
Hello,

I am linking my code to a library. My code is in C++ but the library is in C.

The problem is that whenever the extension of library implementations are c 
(not cpp), they are not linked and I get undefined reference to error.

Here is an example:

Suppose I have
./src/main.cpp   // as main file
./include/lib.h
./include/lib.c  // as a library

And the cmake file is

cmake_minimum_required(VERSION 2.8)
project(myproj)

set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${INCLUDE_DIR})
add_library(MY_LIB ${INCLUDE_DIR}/Lib.c)

set(EXECUTABLE_NAME myproj)
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(myproj ${SOURCE_DIR}/main.cpp)

target_link_libraries(myproj MY_LIB)

This returns undefined reference to error, but if I rename lib.c to lib.cpp, 
everything works fine.

How can I resolve this? I do not want to rename the file to cpp, because there 
are a lot of library files and I prefer to keep the library implementations 
untouched.

Thanks.

--

Powered by www.kitware.comhttp://www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] undefined reference to error when use c extension

2015-06-05 Thread J Decker
it's not the lib, it's the header interface to the lib.

On Fri, Jun 5, 2015 at 7:42 PM, Sunrise helios.cor...@gmail.com wrote:

  Thanks for your reply. I am aware of extern C {} but this is not an
 option for me. As I mentioned, there are a lot of lib files (which were not
 written by me) and I was wondering if lib itself could be untouched.


 On 06/05/2015 07:33 PM, J Decker wrote:

 c++ does name mangling on functions... so functions like 'f' become a much
 more complex name (as shown in the xxx not found in your error messages).
 In order for C++ to not produce a mangled name C functions have to be
 defined as

  extern c void f( void );
 but 'extern c' is not liked by C... so you really need to define in the
 shared header something like...

  #ifdef __cplusplus
 #define CEXTERN extern C
 #ese
 #define CEXTERN
 #endif

  CEXTERN void f( void );

  But of course since you don't know about name mangling I guess you don't
 know proper header usage either.  This is not a cmake issue, but a general
 C++ issue... and you'd do better asking stack exchange or something.

 On Fri, Jun 5, 2015 at 6:37 PM, Sunrise helios.cor...@gmail.com wrote:

  Hello,

 I am linking my code to a library. My code is in C++ but the library is
 in C.

 The problem is that whenever the extension of library implementations are
 c (not cpp), they are not linked and I get undefined reference to
 error.

 Here is an example:

 Suppose I have
 ./src/main.cpp   // as main file
 ./include/lib.h
 ./include/lib.c  // as a library

 And the cmake file is

 cmake_minimum_required(VERSION 2.8)
 project(myproj)

 set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 include_directories(${INCLUDE_DIR})
 add_library(MY_LIB ${INCLUDE_DIR}/Lib.c)

 set(EXECUTABLE_NAME myproj)
 set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
 add_executable(myproj ${SOURCE_DIR}/main.cpp)

 target_link_libraries(myproj MY_LIB)

 This returns undefined reference to error, but if I rename lib.c to
 lib.cpp, everything works fine.

 How can I resolve this? I do not want to rename the file to cpp, because
 there are a lot of library files and I prefer to keep the library
 implementations untouched.

 Thanks.

 --

 Powered by www.kitware.com

 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ

 Kitware offers various services to support the CMake community. For more
 information on each offering, please visit:

 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html

 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html

 Follow this link to subscribe/unsubscribe:
 http://public.kitware.com/mailman/listinfo/cmake




-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Undefined reference

2011-11-04 Thread Hendrik Sattler

Am 03.11.2011 15:51, schrieb Mauricio Klein:

Thank you Raphael, it worked!

One last question: i've tried to compile my code using static 
linkage, once
i need my daemon runs in many Linux releases. But, even static, in 
many

systems my code crashes because the GLIBC version.

My question is: asking for static linkage in CMake can solve this 
problem?

Or maybe another approach in CMake, where i embed all the needed
libraries...

Thanks for your attention!

On Thu, Nov 3, 2011 at 12:19 PM, Raphael Kubo da Costa
rak...@freebsd.orgwrote:


Mauricio Klein
mauricio.klein@gmail.com writes:

 I can compile all my codes without problems, but in the linkage 
step, i
 receive a lot of errors about undefined reference to OpenSSL 
functions

 (yes, my code uses OpenSSL).

 In my own (and ugly :P) Makefile, i use -lssl flag in g++ 
compile line.


 My question is: how can i pass this flag in CMake.
 Also, i'm not sure if i'm using CMake correctly. Is correctly use 
-lssl
 flag in CMake or i need to copy the library to a folder inside my 
project

 and link to this copy?

You need to find OpenSSL with `find_package(OpenSSL)' and then, 
assuming

it is found (ie. OPENSSL_FOUND is true), link to its libraries with
`target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.


After the issues with glibc were already mentioned, be also aware that 
static linking to openssl is really not recommended. Just look at the 
history of security updates to openssl. Do you really want to ship a new 
executable on every update of any statically linked library? Probably 
not.
The only good reason these days to link statically is maybe some 
performance hit shared libraries.


HS

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-04 Thread Mauricio Klein
I see.

Well, i will research about package managers to perform this tasks
automatically. Better than manipulate libraries myself.

Thanks guys for every reply sent!

On Fri, Nov 4, 2011 at 5:00 AM, Hendrik Sattler p...@hendrik-sattler.dewrote:

 Am 03.11.2011 15:51, schrieb Mauricio Klein:

  Thank you Raphael, it worked!

 One last question: i've tried to compile my code using static linkage,
 once
 i need my daemon runs in many Linux releases. But, even static, in many
 systems my code crashes because the GLIBC version.

 My question is: asking for static linkage in CMake can solve this problem?
 Or maybe another approach in CMake, where i embed all the needed
 libraries...

 Thanks for your attention!

 On Thu, Nov 3, 2011 at 12:19 PM, Raphael Kubo da Costa
 rak...@freebsd.orgwrote:

  Mauricio Klein
 mauricio.klein@gmail.com writes:

  I can compile all my codes without problems, but in the linkage step, i
  receive a lot of errors about undefined reference to OpenSSL functions
  (yes, my code uses OpenSSL).
 
  In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile
 line.
 
  My question is: how can i pass this flag in CMake.
  Also, i'm not sure if i'm using CMake correctly. Is correctly use
 -lssl
  flag in CMake or i need to copy the library to a folder inside my
 project
  and link to this copy?

 You need to find OpenSSL with `find_package(OpenSSL)' and then, assuming
 it is found (ie. OPENSSL_FOUND is true), link to its libraries with
 `target_link_libraries(YOUR_**APP ${OPENSSL_LIBRARIES})'.


 After the issues with glibc were already mentioned, be also aware that
 static linking to openssl is really not recommended. Just look at the
 history of security updates to openssl. Do you really want to ship a new
 executable on every update of any statically linked library? Probably not.
 The only good reason these days to link statically is maybe some
 performance hit shared libraries.

 HS


 --

 Powered by www.kitware.com

 Visit other Kitware open-source projects at http://www.kitware.com/**
 opensource/opensource.htmlhttp://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/**CMake_FAQhttp://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/**listinfo/cmakehttp://www.cmake.org/mailman/listinfo/cmake




-- 
Best regards,

Maurício Souza Klein.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Undefined reference

2011-11-04 Thread Michael Hertling
On 11/04/2011 12:50 AM, Dan Kegel wrote:
 On Thu, Nov 3, 2011 at 4:16 PM, Michael Hertling mhertl...@online.de wrote:
 Static linking of glibc is not really supported; IIRC glibc's
 DNS and localization support use shared libraries under
 the hood, even when you ask for static linking

 [statically linked utilities are essential for disaster recovery and during 
 boot]
 
 During boot, I think it's common practice to link against klibc,
 which totally supports static linking.
 And I agree, a statically linked busybox is a wonderful thing.

AFAIK, klibc is even targeted at the Linux early user space; OTOH,
the FAQ of BusyBox states that it is not suitable for the latter.
Instead, uClibc is preferred as a replacement for glibc, but I
have tried neither the one nor the other yet.

 So, what do you mean when saying static linking
 against glibc is not really supported? Do you refer to particular
 systems or special setups? Could you provide an example?
 
 No special system or setup.  See
 http://www.akkadia.org/drepper/no_static_linking.html
 http://stackoverflow.com/questions/3430400/linux-static-linking-is-dead
 http://sourceware.org/bugzilla/show_bug.cgi?id=631
 http://sources.redhat.com/bugzilla/show_bug.cgi?id=1044
 glibc decided many years ago to focus only on systems that
 supported dynamic linking, and to require its use.

Now, I see what you mean with under the hood. ;) You're absolutely
right that for non-trivial programs not written with static linking
against glibc in mind, the latter is quite impossible. Indeed, this
might be the cause of the OP's problems. Nevertheless, if you don't
refer to any of the affected symbols - most notably the NSS stuff -
or do provide drop-in replacements for them, a self-contained static
linking against glibc should still be feasible. E.g., mdadm's static
target compiles the additional file pwgr.c with an implementation of
get{pw,gr}nam(), two critical functions. However, I have not tried
static linking against glibc for some time, and at the moment, I
can't perform a rigorous test since I've no glibc-based system
at hand which I could endanger, so correct me if I'm wrong.

 Not a popular decision, but the glibc maintainer has some rather strong
 opinions.

Yes, but UD's opinions have inspired the development of related
projects, so we've a wider choice of C libraries nowadays. ;-)

@Mauricio: Could you build your project statically with a somewhat
recent gcc as the latter warns when you use critical functions, i.e.
functions that require a dl_open'ing of shared libraries by libc.a?
If this turns out to be the issue, you might try to use a different
C library like the already mentioned klibc or uClibc, but note that
exchanging binaries among *unices won't work unless the systems are
sufficiently compatible, e.g. Linux 2.4 -- 2.6 will probably fail.

Regards,

Michael
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-03 Thread Matt Williams
On 3 November 2011 15:12, Mauricio Klein mauricio.klein@gmail.com wrote:
 Hello guys!
 I'm new in CMake world, and i'm trying to compile a daemon developed a log
 time ago.
 I can compile all my codes without problems, but in the linkage step, i
 receive a lot of errors about undefined reference to OpenSSL functions (yes,
 my code uses OpenSSL).
 In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile line.
 My question is: how can i pass this flag in CMake.

Hi there, maybe this is what you want:

find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
add_executable(my_daemon ${source_files})
target_link_libraries(my_daemon ${OPENSSL_LIBRARIES})

where ${source_files} is a list of your source files created by a set() call.

-- 
Matt Williams
http://milliams.com
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-03 Thread Raphael Kubo da Costa
Mauricio Klein
mauricio.klein@gmail.com writes:

 I can compile all my codes without problems, but in the linkage step, i
 receive a lot of errors about undefined reference to OpenSSL functions
 (yes, my code uses OpenSSL).

 In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile line.

 My question is: how can i pass this flag in CMake.
 Also, i'm not sure if i'm using CMake correctly. Is correctly use -lssl
 flag in CMake or i need to copy the library to a folder inside my project
 and link to this copy?

You need to find OpenSSL with `find_package(OpenSSL)' and then, assuming
it is found (ie. OPENSSL_FOUND is true), link to its libraries with
`target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-03 Thread Mauricio Klein
Thank you Raphael, it worked!

One last question: i've tried to compile my code using static linkage, once
i need my daemon runs in many Linux releases. But, even static, in many
systems my code crashes because the GLIBC version.

My question is: asking for static linkage in CMake can solve this problem?
Or maybe another approach in CMake, where i embed all the needed
libraries...

Thanks for your attention!

On Thu, Nov 3, 2011 at 12:19 PM, Raphael Kubo da Costa
rak...@freebsd.orgwrote:

 Mauricio Klein
 mauricio.klein@gmail.com writes:

  I can compile all my codes without problems, but in the linkage step, i
  receive a lot of errors about undefined reference to OpenSSL functions
  (yes, my code uses OpenSSL).
 
  In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile line.
 
  My question is: how can i pass this flag in CMake.
  Also, i'm not sure if i'm using CMake correctly. Is correctly use -lssl
  flag in CMake or i need to copy the library to a folder inside my project
  and link to this copy?

 You need to find OpenSSL with `find_package(OpenSSL)' and then, assuming
 it is found (ie. OPENSSL_FOUND is true), link to its libraries with
 `target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.

 --

 Powered by www.kitware.com

 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake




-- 
Best regards,

Maurício Souza Klein.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Undefined reference

2011-11-03 Thread Michael Hertling
On 11/03/2011 03:51 PM, Mauricio Klein wrote:
 Thank you Raphael, it worked!
 
 One last question: i've tried to compile my code using static linkage, once
 i need my daemon runs in many Linux releases. But, even static, in many
 systems my code crashes because the GLIBC version.

How do these crashes manifest themselves, e.g. shell/syslog messages,
return values, core dumps etc.? Are you sure they are related to the
GLIBC version? Does the executable actually have no single dependency
on any shared library, i.e. is it linked statically in its entirety?
What does ldd or readelf report?

 My question is: asking for static linkage in CMake can solve this problem?

If even a statically linked executable crashes on the target system,
telling CMake to link statically will hardly solve this problem. ;)

 Or maybe another approach in CMake, where i embed all the needed
 libraries...

You might take a look the the BundleUtilities Module, but at first,
I'd recommend to investigate what exactly causes the crashes. Your
best bet is probably to provide a tiny but self-contained example
that works on your development platform and crashes on a target
system, along with some information about the latter's setup.

Regards,

Michael

 On Thu, Nov 3, 2011 at 12:19 PM, Raphael Kubo da Costa
 rak...@freebsd.orgwrote:
 
 Mauricio Klein
 mauricio.klein@gmail.com writes:

 I can compile all my codes without problems, but in the linkage step, i
 receive a lot of errors about undefined reference to OpenSSL functions
 (yes, my code uses OpenSSL).

 In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile line.

 My question is: how can i pass this flag in CMake.
 Also, i'm not sure if i'm using CMake correctly. Is correctly use -lssl
 flag in CMake or i need to copy the library to a folder inside my project
 and link to this copy?

 You need to find OpenSSL with `find_package(OpenSSL)' and then, assuming
 it is found (ie. OPENSSL_FOUND is true), link to its libraries with
 `target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-03 Thread Mauricio Klein
The error reported occurs in the launch time: the daemon doesn't starts and
report (in terminal) a GLIBC version error. I mean, the daemon was compiled
in a old CentOS (4.8) and i'm trying to run in the latest Ubuntu.

But anyway, i will make more tests as you sugested and try to discovery
what exactly is happening.

Once again, thank you so much for your help!

On Thu, Nov 3, 2011 at 3:09 PM, Michael Hertling mhertl...@online.dewrote:

 On 11/03/2011 03:51 PM, Mauricio Klein wrote:
  Thank you Raphael, it worked!
 
  One last question: i've tried to compile my code using static linkage,
 once
  i need my daemon runs in many Linux releases. But, even static, in many
  systems my code crashes because the GLIBC version.

 How do these crashes manifest themselves, e.g. shell/syslog messages,
 return values, core dumps etc.? Are you sure they are related to the
 GLIBC version? Does the executable actually have no single dependency
 on any shared library, i.e. is it linked statically in its entirety?
 What does ldd or readelf report?

  My question is: asking for static linkage in CMake can solve this
 problem?

 If even a statically linked executable crashes on the target system,
 telling CMake to link statically will hardly solve this problem. ;)

  Or maybe another approach in CMake, where i embed all the needed
  libraries...

 You might take a look the the BundleUtilities Module, but at first,
 I'd recommend to investigate what exactly causes the crashes. Your
 best bet is probably to provide a tiny but self-contained example
 that works on your development platform and crashes on a target
 system, along with some information about the latter's setup.

 Regards,

 Michael

  On Thu, Nov 3, 2011 at 12:19 PM, Raphael Kubo da Costa
  rak...@freebsd.orgwrote:
 
  Mauricio Klein
  mauricio.klein@gmail.com writes:
 
  I can compile all my codes without problems, but in the linkage step, i
  receive a lot of errors about undefined reference to OpenSSL functions
  (yes, my code uses OpenSSL).
 
  In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile
 line.
 
  My question is: how can i pass this flag in CMake.
  Also, i'm not sure if i'm using CMake correctly. Is correctly use
 -lssl
  flag in CMake or i need to copy the library to a folder inside my
 project
  and link to this copy?
 
  You need to find OpenSSL with `find_package(OpenSSL)' and then, assuming
  it is found (ie. OPENSSL_FOUND is true), link to its libraries with
  `target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.
 --

 Powered by www.kitware.com

 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake




-- 
Best regards,

Maurício Souza Klein.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Undefined reference

2011-11-03 Thread Michael Hertling
On 11/03/2011 06:20 PM, Mauricio Klein wrote:
 The error reported occurs in the launch time: the daemon doesn't starts and
 report (in terminal) a GLIBC version error. [...]

Usually, this means that it has *not* been linked statically against
the GLIBC on the build system. Which dependencies does ldd report?

 [...] I mean, the daemon was compiled
 in a old CentOS (4.8) and i'm trying to run in the latest Ubuntu.
 
 But anyway, i will make more tests as you sugested and try to discovery
 what exactly is happening.
 
 Once again, thank you so much for your help!
 
 On Thu, Nov 3, 2011 at 3:09 PM, Michael Hertling mhertl...@online.dewrote:
 
 On 11/03/2011 03:51 PM, Mauricio Klein wrote:
 Thank you Raphael, it worked!

 One last question: i've tried to compile my code using static linkage,
 once
 i need my daemon runs in many Linux releases. But, even static, in many
 systems my code crashes because the GLIBC version.

 How do these crashes manifest themselves, e.g. shell/syslog messages,
 return values, core dumps etc.? Are you sure they are related to the
 GLIBC version? Does the executable actually have no single dependency
 on any shared library, i.e. is it linked statically in its entirety?
 What does ldd or readelf report?

 My question is: asking for static linkage in CMake can solve this
 problem?

 If even a statically linked executable crashes on the target system,
 telling CMake to link statically will hardly solve this problem. ;)

 Or maybe another approach in CMake, where i embed all the needed
 libraries...

 You might take a look the the BundleUtilities Module, but at first,
 I'd recommend to investigate what exactly causes the crashes. Your
 best bet is probably to provide a tiny but self-contained example
 that works on your development platform and crashes on a target
 system, along with some information about the latter's setup.

 Regards,

 Michael

 On Thu, Nov 3, 2011 at 12:19 PM, Raphael Kubo da Costa
 rak...@freebsd.orgwrote:

 Mauricio Klein
 mauricio.klein@gmail.com writes:

 I can compile all my codes without problems, but in the linkage step, i
 receive a lot of errors about undefined reference to OpenSSL functions
 (yes, my code uses OpenSSL).

 In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile
 line.

 My question is: how can i pass this flag in CMake.
 Also, i'm not sure if i'm using CMake correctly. Is correctly use
 -lssl
 flag in CMake or i need to copy the library to a folder inside my
 project
 and link to this copy?

 You need to find OpenSSL with `find_package(OpenSSL)' and then, assuming
 it is found (ie. OPENSSL_FOUND is true), link to its libraries with
 `target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-03 Thread Mauricio Klein
ldd reports that is not dynamically executable, as expected. But even ldd
saying that, the problem with GLIBC occurs.

On Thu, Nov 3, 2011 at 3:33 PM, Michael Hertling mhertl...@online.dewrote:

 On 11/03/2011 06:20 PM, Mauricio Klein wrote:
  The error reported occurs in the launch time: the daemon doesn't starts
 and
  report (in terminal) a GLIBC version error. [...]

 Usually, this means that it has *not* been linked statically against
 the GLIBC on the build system. Which dependencies does ldd report?

  [...] I mean, the daemon was compiled
  in a old CentOS (4.8) and i'm trying to run in the latest Ubuntu.
 
  But anyway, i will make more tests as you sugested and try to discovery
  what exactly is happening.
 
  Once again, thank you so much for your help!
 
  On Thu, Nov 3, 2011 at 3:09 PM, Michael Hertling mhertl...@online.de
 wrote:
 
  On 11/03/2011 03:51 PM, Mauricio Klein wrote:
  Thank you Raphael, it worked!
 
  One last question: i've tried to compile my code using static linkage,
  once
  i need my daemon runs in many Linux releases. But, even static, in many
  systems my code crashes because the GLIBC version.
 
  How do these crashes manifest themselves, e.g. shell/syslog messages,
  return values, core dumps etc.? Are you sure they are related to the
  GLIBC version? Does the executable actually have no single dependency
  on any shared library, i.e. is it linked statically in its entirety?
  What does ldd or readelf report?
 
  My question is: asking for static linkage in CMake can solve this
  problem?
 
  If even a statically linked executable crashes on the target system,
  telling CMake to link statically will hardly solve this problem. ;)
 
  Or maybe another approach in CMake, where i embed all the needed
  libraries...
 
  You might take a look the the BundleUtilities Module, but at first,
  I'd recommend to investigate what exactly causes the crashes. Your
  best bet is probably to provide a tiny but self-contained example
  that works on your development platform and crashes on a target
  system, along with some information about the latter's setup.
 
  Regards,
 
  Michael
 
  On Thu, Nov 3, 2011 at 12:19 PM, Raphael Kubo da Costa
  rak...@freebsd.orgwrote:
 
  Mauricio Klein
  mauricio.klein@gmail.com writes:
 
  I can compile all my codes without problems, but in the linkage
 step, i
  receive a lot of errors about undefined reference to OpenSSL
 functions
  (yes, my code uses OpenSSL).
 
  In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile
  line.
 
  My question is: how can i pass this flag in CMake.
  Also, i'm not sure if i'm using CMake correctly. Is correctly use
  -lssl
  flag in CMake or i need to copy the library to a folder inside my
  project
  and link to this copy?
 
  You need to find OpenSSL with `find_package(OpenSSL)' and then,
 assuming
  it is found (ie. OPENSSL_FOUND is true), link to its libraries with
  `target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.
 --

 Powered by www.kitware.com

 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake




-- 
Best regards,

Maurício Souza Klein.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Undefined reference

2011-11-03 Thread Michael Hertling
On 11/03/2011 06:39 PM, Mauricio Klein wrote:
 ldd reports that is not dynamically executable, as expected. But even ldd
 saying that, the problem with GLIBC occurs.

What exactly does ldd report, and how exactly the executable is linked?

Regards,

Michael

 On Thu, Nov 3, 2011 at 3:33 PM, Michael Hertling mhertl...@online.dewrote:
 
 On 11/03/2011 06:20 PM, Mauricio Klein wrote:
 The error reported occurs in the launch time: the daemon doesn't starts
 and
 report (in terminal) a GLIBC version error. [...]

 Usually, this means that it has *not* been linked statically against
 the GLIBC on the build system. Which dependencies does ldd report?

 [...] I mean, the daemon was compiled
 in a old CentOS (4.8) and i'm trying to run in the latest Ubuntu.

 But anyway, i will make more tests as you sugested and try to discovery
 what exactly is happening.

 Once again, thank you so much for your help!

 On Thu, Nov 3, 2011 at 3:09 PM, Michael Hertling mhertl...@online.de
 wrote:

 On 11/03/2011 03:51 PM, Mauricio Klein wrote:
 Thank you Raphael, it worked!

 One last question: i've tried to compile my code using static linkage,
 once
 i need my daemon runs in many Linux releases. But, even static, in many
 systems my code crashes because the GLIBC version.

 How do these crashes manifest themselves, e.g. shell/syslog messages,
 return values, core dumps etc.? Are you sure they are related to the
 GLIBC version? Does the executable actually have no single dependency
 on any shared library, i.e. is it linked statically in its entirety?
 What does ldd or readelf report?

 My question is: asking for static linkage in CMake can solve this
 problem?

 If even a statically linked executable crashes on the target system,
 telling CMake to link statically will hardly solve this problem. ;)

 Or maybe another approach in CMake, where i embed all the needed
 libraries...

 You might take a look the the BundleUtilities Module, but at first,
 I'd recommend to investigate what exactly causes the crashes. Your
 best bet is probably to provide a tiny but self-contained example
 that works on your development platform and crashes on a target
 system, along with some information about the latter's setup.

 Regards,

 Michael

 On Thu, Nov 3, 2011 at 12:19 PM, Raphael Kubo da Costa
 rak...@freebsd.orgwrote:

 Mauricio Klein
 mauricio.klein@gmail.com writes:

 I can compile all my codes without problems, but in the linkage
 step, i
 receive a lot of errors about undefined reference to OpenSSL
 functions
 (yes, my code uses OpenSSL).

 In my own (and ugly :P) Makefile, i use -lssl flag in g++ compile
 line.

 My question is: how can i pass this flag in CMake.
 Also, i'm not sure if i'm using CMake correctly. Is correctly use
 -lssl
 flag in CMake or i need to copy the library to a folder inside my
 project
 and link to this copy?

 You need to find OpenSSL with `find_package(OpenSSL)' and then,
 assuming
 it is found (ie. OPENSSL_FOUND is true), link to its libraries with
 `target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-03 Thread Dan Kegel
On Thu, Nov 3, 2011 at 7:51 AM, Mauricio Klein
mauricio.klein@gmail.com wrote:
 One last question: i've tried to compile my code using static linkage, once
 i need my daemon runs in many Linux releases.

Static linking of glibc is not really supported; IIRC glibc's
DNS and localization support use shared libraries under
the hood, even when you ask for static linking... and
since these are internal interfaces, they have changed
in incompatible ways in the past.  So beware!
While it may be ok to link statically to most libraries,
glibc should always be linked dynamically.

If you are still having problems after going back to
dynamically linking with glibc, please post source code
for a tiny test program that exhibits the problem, along
with how you built and tested it, and the log showing the
failure.
- Dan
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-03 Thread Michael Hertling
On 11/03/2011 10:18 PM, Dan Kegel wrote:
 On Thu, Nov 3, 2011 at 7:51 AM, Mauricio Klein
 mauricio.klein@gmail.com wrote:
 One last question: i've tried to compile my code using static linkage, once
 i need my daemon runs in many Linux releases.
 
 Static linking of glibc is not really supported; IIRC glibc's
 DNS and localization support use shared libraries under
 the hood, even when you ask for static linking... and
 since these are internal interfaces, they have changed
 in incompatible ways in the past.  So beware!
 While it may be ok to link statically to most libraries,
 glibc should always be linked dynamically.

If you will ever meet with a little accident while updating glibc
without a package manager, a common procedure is to use statically
linked utilities, i.e. utilities capable to run without the ruined
glibc, at least in order to repair symlinks, e.g. Another occasion
for the use of statically linked executables without any reference
to glibc and friends is an initramfs that often doesn't have a lib
directory at all. So, what do you mean when saying static linking
against glibc is not really supported? Do you refer to particular
systems or special setups? Could you provide an example?

 If you are still having problems after going back to
 dynamically linking with glibc, please post source code
 for a tiny test program that exhibits the problem, along
 with how you built and tested it, and the log showing the
 failure.

Yep, message after failed invocation, ldd, linker command etc.

Regards,

Michael
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference

2011-11-03 Thread Dan Kegel
On Thu, Nov 3, 2011 at 4:16 PM, Michael Hertling mhertl...@online.de wrote:
 Static linking of glibc is not really supported; IIRC glibc's
 DNS and localization support use shared libraries under
 the hood, even when you ask for static linking

[statically linked utilities are essential for disaster recovery and during 
boot]

During boot, I think it's common practice to link against klibc,
which totally supports static linking.
And I agree, a statically linked busybox is a wonderful thing.

 So, what do you mean when saying static linking
 against glibc is not really supported? Do you refer to particular
 systems or special setups? Could you provide an example?

No special system or setup.  See
http://www.akkadia.org/drepper/no_static_linking.html
http://stackoverflow.com/questions/3430400/linux-static-linking-is-dead
http://sourceware.org/bugzilla/show_bug.cgi?id=631
http://sources.redhat.com/bugzilla/show_bug.cgi?id=1044
glibc decided many years ago to focus only on systems that
supported dynamic linking, and to require its use.
Not a popular decision, but the glibc maintainer has some rather strong
opinions.
- Dan
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Undefined reference to __Unwind_Resume when building a universal binary with make on Mac OS X

2010-09-13 Thread Ryan Pavlik

 if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
endif()

Hope this helps!

Ryan

On 9/10/10 9:19 AM, Pedro d'Aquino wrote:
The problem wasn't related to the universal binaries, but to the SDK 
used (10.5). I need to add -mmacosx-version-min=10.5 to the compiler 
flags in order to make it work.


Shouldn't this be handled automatically by CMake?

On Fri, Sep 10, 2010 at 8:46 AM, Pedro d'Aquino bud...@gmail.com 
mailto:bud...@gmail.com wrote:


Hi everyone,

I'm currently modifying an existing CMake-based project to build
universal binaries on 10.6.4. Xcode 3.2.3 builds the new project
fine, but the make-based compilation fails because of an undefined
symbol, __Unwind_Resume.

The actual command used for compiling each C++ file is (from
VERBOSE=1):
/usr/bin/c++-Wall -Wno-multichar -O2 -g -Wall -Wno-multichar
-arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk 

After all files are compiled successfully, linking fails with the
following message:

Undefined symbols:
  __Unwind_Resume, referenced from:
  macosx::MacLibraryLoader::release(ILibraryInterface**)in
mac_library_loader.cpp.o
  macosx::MacLibraryLoader::getInterface()in
mac_library_loader.cpp.o

 macosx::MacLibraryLoader::MacLibraryLoader(std::basic_stringchar, std::char_traitschar,

std::allocatorchar  const)in mac_library_loader.cpp.o
  .

It seems __Unwind_Resume is referenced in just about every .cpp
file I compile.

The only change I've made from my original, i386-only project was add

if(APPLE)
SET(CMAKE_OSX_ARCHITECTURES i386;x86_64)
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
endif()

Does anyone know what is going on?

Thanks a lot,

Pedro d'Aquino






___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake



--
Ryan Pavlik
Human-Computer Interaction Graduate Student
Virtual Reality Applications Center
Iowa State University

http://academic.cleardefinition.com/

___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Undefined reference to __Unwind_Resume when building a universal binary with make on Mac OS X

2010-09-10 Thread Pedro d'Aquino
The problem wasn't related to the universal binaries, but to the SDK used
(10.5). I need to add -mmacosx-version-min=10.5 to the compiler flags in
order to make it work.

Shouldn't this be handled automatically by CMake?

On Fri, Sep 10, 2010 at 8:46 AM, Pedro d'Aquino bud...@gmail.com wrote:

 Hi everyone,

 I'm currently modifying an existing CMake-based project to build universal
 binaries on 10.6.4. Xcode 3.2.3 builds the new project fine, but the
 make-based compilation fails because of an undefined symbol,
 __Unwind_Resume.

 The actual command used for compiling each C++ file is (from VERBOSE=1):
 /usr/bin/c++-Wall -Wno-multichar -O2 -g -Wall -Wno-multichar -arch i386
 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk 

 After all files are compiled successfully, linking fails with the following
 message:

 Undefined symbols:
   __Unwind_Resume, referenced from:
   macosx::MacLibraryLoader::release(ILibraryInterface**)in
 mac_library_loader.cpp.o
   macosx::MacLibraryLoader::getInterface()in
 mac_library_loader.cpp.o
   macosx::MacLibraryLoader::MacLibraryLoader(std::basic_stringchar,
 std::char_traitschar, std::allocatorchar  const)in
 mac_library_loader.cpp.o
   .

 It seems __Unwind_Resume is referenced in just about every .cpp file I
 compile.

 The only change I've made from my original, i386-only project was add

 if(APPLE)
 SET(CMAKE_OSX_ARCHITECTURES i386;x86_64)
  set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
 endif()

 Does anyone know what is going on?

 Thanks a lot,

 Pedro d'Aquino





___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] undefined reference to memcpy ?

2006-06-13 Thread Alexander Neundorf

Von: Alexander Neundorf [EMAIL PROTECTED]

 Hi,
 
 I have three libraries here, libA, libB and libC. All three are linked as
 shared libs. libB and libC are written in C++ but have a C interface, libA
 is completely C.
 When trying to link libC, which links to libB, which links to libA I get
 undefined references to memcpy (but only from one of the object files).
 I have no idea what could be the reason for this problem. 
 
 Any ideas ?
 I have no special linker flags set.
 This is on SUSE 10.0 using gcc 4.0.2

Ok, I found it.
In one of the headers was 
#pragma GCC visibility push(hidden)
which caused the linker not to find memcpy(). Removing it helped.

Alex

-- 


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake