Compiling issues with check and autotools - automake

I have some C unit tests with check framework.
My Makefile.am looks like:
check_PROGRAMS = check_fseqs
check_fseqs_SOURCES = tests/check_fseqs.c
check_fseqs_LDADD = -lcheck
File structure is (some files were omitted):
.
|-- Makefile.am
|-- configure.ac
|-- src
| |-- fseqs.c
| |-- fseqs.h
| |-- fseqs.o
`-- tests
`-- check_fseqs.c
Then I run make check and it throws:
$ make check
/Applications/Xcode.app/Contents/Developer/usr/bin/make check_fseqs
gcc -g -O2 -o check_fseqs tests/check_fseqs.o -lcheck
Undefined symbols for architecture x86_64:
"_f_msb", referenced from:
_test_f_msb in check_fseqs.o
"_min", referenced from:
_test_min in check_fseqs.o
"_substract", referenced from:
_test_substract in check_fseqs.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [check_fseqs] Error 1
make: *** [check-am] Error 2
What is wrong?

You're missing a dependency. If you're building fseqs.o, you need to add it as check_DEPENDENCIES and also add it to your check_LDADD line. If it was a library, you'd do the same thing, specifying the library file instead of all of the object files making the library up.
The check_DEPENDENCIES bit ensures the correct rule is generated, and the check_LDADD ensures the file is added to the command line while linking.

Related

Adding snappy-c to c++ project

I am using cmake for the first time and was trying to add snappy-c to my c++ project. I compiled the snappy-c library using the Makefile in its repo. I was hoping that adding the snappy.o to my CMakeLists.txt would allow me to use the snappy library. Unfortunately, that gives me an undefined reference error.
How can I correctly add snappy-c to my c++ project?
My directory structure is
server-side
├── src
│── common_main.cpp
├── include
└── libs/snappy-c
This is my CMakeLists.txt file
cmake_minimum_required(VERSION 3.5)
add_definitions(-std=c++11)
# include public headers
include_directories("include" ${CMAKE_CURRENT_SOURCE_DIR}/libs/snappy-c)
# recursively add .cpp files to the SOURCES variable
file(GLOB_RECURSE SOURCES "src/*.cpp" main.cpp)
# create executable using SOURCES
add_executable(common-main ${SOURCES})
target_link_libraries(
common-main
${CMAKE_CURRENT_SOURCE_DIR}/libs/snappy-c/snappy.o
)
find_library(LIBRT rt)
if(LIBRT)
target_link_libraries(common-main ${LIBRT})
endif()
The code for which I get undefined reference is
#include <iostream>
#include "snappy.h"
int main(){
struct snappy_env env;
snappy_init_env(&env);
}
On running make VERBOSE=1, I get the following output
cd /home/kakashi/Workbench/project/build/server-side && /usr/bin/cmake -E cmake_link_script CMakeFiles/common-main.dir/link.txt --verbose=1
/usr/bin/c++ -pthread CMakeFiles/common-main.dir/src/common_main.cpp.o CMakeFiles/common-main.dir/src/server_service.cpp.o CMakeFiles/common-main.dir/src/service_manager.cpp.o -o common-main ../../server-side/libs/snappy.o /usr/lib/x86_64-linux-gnu/librt.so
CMakeFiles/common-main.dir/src/common_main.cpp.o: In function `main':
common_main.cpp:(.text+0x399): undefined reference to `snappy_init_env(snappy_env*)'
collect2: error: ld returned 1 exit status
server-side/CMakeFiles/common-main.dir/build.make:200: recipe for target 'server-side/common-main' failed
make[2]: *** [server-side/common-main] Error 1
.Makefile:83: recipe for target 'all' failed
.
.
.
.

Failed to parse message file:Requested alignment is not a power of 2

I'm trying to build a standard program in tinyos. The Makefile looks like this:
COMPONENT=TestSerialAppC
BUILD_EXTRA_DEPS += TestSerial.class
CLEAN_EXTRA = *.class TestSerialMsg.java
CFLAGS += -I$(TOSDIR)/lib/T2Hack
TestSerial.class: $(wildcard *.java) TestSerialMsg.java
javac -target 1.4 -source 1.4 *.java
TestSerialMsg.java:
mig java -target=null $(CFLAGS) -java-classname=TestSerialMsg
TestSerial.h test_serial_msg -o $#
include $(MAKERULES)
And when I make it, there is error:
In file included from /usr/lib/ncc/deputy_nodeputy.h:4:
/usr/lib/gcc/i686-linux-gnu/5/include/stddef.h:429: requested alignment
is not a power of 2
failed to parse message file TestSerial.h
Makefile:11: recipe for target 'TestSerialMsg.java' failed
make: *** [TestSerialMsg.java] Error 1
I have no idea why this happened and how I can solve it. Is this a problem of gcc or a problem of java?
Edit: When I execute those commands in command line, I found the problem resides in:
mig java -target=null -I$(TOSDIR)/lib/T2Hack -java-classname=TestSerialMsg
TestSerial.h test_serial_msg -o TestSerialMsg.java
mig is a message interface generator for nesC. And I think it is because I use a wrong version of gcc while calling mig.

Error when compiling a cydia tweak

So I have been working on a simple tweak and it literally took me 5 minutes to get the code written. However, I am getting this error now while I compile the tweak!
Here is the error:
Making all for tweak UltraVipPro...
`Making all for tweak UltraVipPro...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Linking tweak UltraVipPro...
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_UIAlertView", referenced from:
objc-class-ref in Tweak.xm.9fe5fe6c.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [obj/UltraVipPro.dylib.ba964c90.unsigned] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [UltraVipPro.all.tweak.variables] Error 2
The make file code is here:
export ARCHS = armv7 armv7s arm64
export TARGET = iphone:clang:8.1:8.1
export SDKVERSION=8.1
include theos/makefiles/common.mk
TWEAK_NAME = UltraVipPro
UltraVipPro_FILES = Tweak.xm
UltravipPro_FRAMEWORKS = UIKit
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"
Please help me!
1- Make sure that you have this in your Tweak.xm file:
#import <UIKit/UIKit.h>
2- If that doesn't work, remove that header file import and use this instead:
#interface SpringBoard : NSObject
#end
im using this :
ARCHS = armv7 arm64
instead of this :
export ARCHS = armv7 armv7s arm64
remove the export

"Undefined symbols for architecture x86_64:"

I am attempting to compile this library on mac os x Mavericks 10.9.3 64-bit: http://www.openfec.org/downloads.html
I followed the README exactly, and got this error:
Linking C shared library ../../bin/Release/libopenfec.dylib
Undefined symbols for architecture x86_64:
"_of_add_from_multiple_symbols", referenced from:
_of_linear_binary_code_backward_substitution in of_ml_tool.c.o
"_of_add_to_symbol", referenced from:
_of_linear_binary_code_decode_with_new_symbol in of_it_decoding.c.o
_of_linear_binary_code_simplify_linear_system in of_ml_decoding.c.o
_of_linear_binary_code_col_forward_elimination_pivot_reordering in of_ml_tool.c.o
_of_linear_binary_code_apply_gauss_pivoting in of_ml_tool_2.c.o
_of_linear_binary_code_inject_symbol_in_triangular_system in of_ml_tool_2.c.o
_of_linear_binary_code_solve_triangular_system in of_ml_tool_2.c.o
_of_linear_binary_code_invert_dense_system in of_ml_tool_2.c.o
...
"_of_calloc", referenced from...:
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: * [../bin/Release/libopenfec.dylib] Error 1
make[1]: * [src/CMakeFiles/openfec.dir/all] Error 2
make: *** [all] Error 2
I simply followed the README for OpenFEC's distro (found at http://www.openfec.org/downloads.html). When attempting to make, this error arises.
I have no idea what the problem is.
This is what I did after untarring the distribution:
(1.): mkdir build
(2.): cd build
(3.): cmake .. -DDEBUG:STRING=OFF
(4.): make
Any ideas?
Edit: Attempted to force cmake to use 64-bit, still didn't work.
(Tried to force it into 32-bit just for kicks, also didn't work)
FYI, if this wasn't resolved. Check that you're linking to your libraries properly.
FIND_LIBRARY(LIB_NAME_LIB lib)
TARGET_LINK_LIBRARIES(my_executable ${LIB_NAME_LIB})
In your CMakeLists.txt file.

Problems Compiling PySide on MacOSX

I'm trying to compile PySide on a Mac (to use it with a software that has its own Python interpreter, that's why I can't use the binaries installers), and I have some issues I don't know how to solve...
I am using mac 10.8, and all dependencies (Cmake, XCode...) are up-to-date.
I don't know what's wrong, and I am now out of ideas.
here is the last part of what the compiler tells me:
Linking CXX executable testcontainer
[ 39%] Built target testcontainer
[ 39%] Generating testctorinformation.moc
Scanning dependencies of target testctorinformation
[ 39%] Building CXX object ApiExtractor/tests/CMakeFiles/testctorinformation.dir/testctorinformation.cpp.o
1 warning generated.
Linking CXX executable testcodeinjection
Undefined symbols for architecture x86_64:
"QCoreApplication::QCoreApplication(int&, char**, int)", referenced from:
TestCodeInjections::testReadFileUtf8() in testcodeinjection.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [ApiExtractor/tests/testcodeinjection] Error 1
make[1]: *** [ApiExtractor/tests/CMakeFiles/testcodeinjection.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/tests/testconversionruletag.cpp:26:
In file included from /Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/tests/testutil.h:27:
In file included from /Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/abstractmetabuilder.h:28:
/Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/abstractmetalang.h:1347:10: warning:
private field 'm_reserveIn file included from /Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/tests/testconversionoperator.cpp:26:
In file included from /Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/tests/testutil.h:27:
In file included from /Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/abstractmetabuilder.h:28:
/Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/abstractmetalang.h:1347:10: warning:
private field 'm_reserved' is not used [-Wunused-private-field]
d' is not used [-Wunused-private-field]
uint m_reserved : 31;
^
uint m_reserved : 31;
^
1 warning generated.
Linking CXX executable testconversionruletag
[ 39%] Built target testconversionruletag
1 warning generated.
Linking CXX executable testconversionoperator
[ 39%] Built target testconversionoperator
In file included from /Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/tests/testctorinformation.cpp:25:
In file included from /Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/abstractmetabuilder.h:28:
/Users/jle_guen/Desktop/C4D MAC/BuildScripts-master/shiboken/ApiExtractor/abstractmetalang.h:1347:10: warning:
private field 'm_reserved' is not used [-Wunused-private-field]
uint m_reserved : 31;
^
1 warning generated.
Linking CXX executable testctorinformation
[ 39%] Built target testctorinformation
make: *** [all] Error 2

Resources