CMakeFiles/mqcreate.dir/mqcreate1.cc.o: In function main':
mqcreate1.cc:(.text+0xa0): undefined reference tomq_open'
mqcreate1.cc:(.text+0xad): undefined reference to `mq_close'
            Asked
            
        
        
            Active
            
        
            Viewed 701 times
        
    0
            
            
         
    
    
        Eric lee
        
- 23
- 1
- 
                    You need to link against the correct libraries to use these functions. Refer to `man mq_open` on Ubuntu. It should tell you which one to use. – fdk1342 May 24 '19 at 12:34
1 Answers
2
            Try this:
   find_library(LIBRT rt) 
   if(LIBRT)
      target_link_libraries(target_name ${LIBRT})
   endif()
 
    
    
        Bulat
        
- 720
- 7
- 15
- 
                    
- 
                    @Ericlee Because it's not a compile option but a library used during linking. `find_library` is probably overkill and `target_link_libraries(target_name rt)` should suffice because it's a standard OS library that the linker can find on it's own. – fdk1342 May 25 '19 at 22:44