undefined reference error when building program using shared library that link static library
I built AWS WebRTC library as static library and made some shared library using it. As I understand, the static library should be included to the shared library if I make the shared library with the static library. But "undefined reference to ''" error(about the WebRTC library) happens if I build a program using the shared library.
Undefined reference error when building a program using the shared library
arm-linux-gnueabihf-g++ .obj/main.o -Wl,-rpath=/lib -Llibs -lpthread -lmysharedlib -o KeyWeDoorbell
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `getStateMachineCurrentState'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `mbedtls_x509write_crt_der'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `compareJsonString'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `initializeEndianness'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `mbedtls_x509_crt_parse_file'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `hashTableCreateWithParams'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `usrsctp_conninput'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `stackQueueRemoveItem'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `putInt32'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `lws_service'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `globalUnlockMutex'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `onDataChannel'
....
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: libs/libkeywe.so: undefined reference to `globalGetTime'
collect2: error: ld returned 1 exit status
Build the shared library
arm-linux-gnueabihf-g++ -shared .obj/aws_webrtc_test.o -lpthread -Llibs -Bstatic -lkvsWebrtcClient -lkvsWebrtcSignalingClient -o mysharedlib.so
-------------------------- Edit ----------------------------
I tried to build a program that use the static library directly but it works well. So I thought it is because of Scope(PUBLIC/INTERFACE/PRIVATE) of target_link_libraries in the library CMakefile.
So I changed it like this
add_library(kvsWebrtcClient ${LINKAGE} ${WEBRTC_CLIENT_SOURCE_FILES})
target_link_libraries(
kvsWebrtcClient
PUBLIC kvspicUtils
kvspicState
${CMAKE_THREAD_LIBS_INIT}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
${SRTP_LIBRARIES}
${Usrsctp}
${MBEDTLS_LIBRARIES}
${GPERFTOOLS_MALLOC_LIBRARIES}
${GPERFTOOLS_PROFILER_LIBRARIES}
${EXTRA_DEPS})
add_library(kvsWebrtcSignalingClient ${LINKAGE} ${WEBRTC_SIGNALING_CLIENT_SOURCE_FILES})
target_link_libraries(
kvsWebrtcSignalingClient
PUBLIC kvsCommonLws
${LIBWEBSOCKETS_LIBRARIES}
kvspicUtils
kvspicState
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_DEPS}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
${GPERFTOOLS_MALLOC_LIBRARIES}
${GPERFTOOLS_PROFILER_LIBRARIES}
${MBEDTLS_LIBRARIES})
But it is the same. Is there anyone who know how to fix it?
See also questions close to this topic
-
Trouble finding output in ARMsim
Hi I'm currently working on a project and I feel dumb for not knowing this, but I'm having trouble seeing some outputs in my code. I've attached an image of what I'm seeing below and I've checked the console, stdout, and watchView and nothing is showing. Is there something I didn't include in my code or something I'm overlooking?
Edit: I realize it might be important to say that my end goal is to analyze the integers in integer.dat and look at stuff like the total number of integers in the file and any number of occurrences of the same integer(if any)
.equ SWI_Open, 0x66 @open file .equ SWI_Close,0x68 @ close file .equ SWI_PrChr,0x00 @display an ascii char to stdout .equ SWI_PrStr,0x69 @write string to file or stdout .equ SWI_PrInt,0x6b @write an integer to file .equ SWI_RdInt,0x6c @read an integer from a fike .equ Stdout,1 @set output goal to be stdout .equ SWI_Exit, 0x11 @prevent execution .global_start: .text @print an preliminary message to the screen mov R0,#Stdout @print an initial message ldr R1, = Message1 @load cope with of message1 label swi SWI_PrStr @display message to stdout @------------open file---------- ldr r0, = integerFile @set call for input document mov r1,#0 @mode is input swi SWI_Open @open record for input bcs InFileError @check bring-bit(C): if =1 then error @--------file error handling------------ InFileError: mov R0,#Stdout ldr R1, = errMsg swi SWI_PrStr integerFile: .asciz "input.dat" errMsg: .asciz "failed to open input.dia" Message1: .asciz "Hello\n"
-
Does this statement turn into a nop?
I am wondering if the code below, when the line
#define PRINT_STATEMENT
is commented out, will take many CPU cycles to execute on an ARM microcontroller:#define PRINT_STATEMENT 1 #if PRINT_STATEMENT #define PRINT_DBG(...) printf(__VA_ARGS__) #else #define PRINT_DBG(...) #endif int main(){ PRINT_DBG("Hello World\n"); return 0; }
I tested commenting out the
#define PRINT_STATEMENT
line on an online C compiler and can see that the print statement did not get executed. However, I am still wondering if the program were to be flashed onto an ARM microcontroller (with arm_gcc), will that line be turned into anop
operation?Thank you!
-
Having trouble loading address in ARM
Hi I'm doing a personal project in ARMsim. I am trying to open a document and display a message from the file but an error keeps appearing, "undefined symbol message1." Can anyone help?
.equ SWI_Close,0x68 @ close a file .equ SWI_PrChr,0x00 @write an ascii char to stdout .equ SWI_PrStr,0x69 @write a null-ending string .equ SWI_PrInt,0x6b @write an integer .equ SWI_RdInt,0x6c @read an integer from a fike .equ Stdout,1 @set output goal to be stdout .equ SWI_Exit, 0x11 @prevent execution .global_start: .text @print an preliminary message to the screen mov R0,#Stdout @print an initial message ldr R1, = Message1 @load cope with of message1 label swi SWI_PrStr @display message to stdout ```
-
How to getStats() in WebRTC iOS SDK in Swift?
I am trying to get ICE Candidate Pair Stats in iOS SDK in Swift. I see this specific interface:
statsForTrack
but I am unsure about how to use it. Has anybody done this before? -
What's the difference between Simulcast and SVC in WebRTC?
After reading about Scalable Video Coding (SVC) and Simulcast on these links, I cannot tell what are the advantages of using one versus the other.
So I am curious, what are the differences, pros, and cons between SVC and Simulcast?
Does it make sense to use both techniques together?
Thanks
-
websocket client does not recieve event emitted from server
I was trying to create video conferencing application where one user create offer and emit to signalling server and the signalling server will forward the data to another peer but the problem is when the peer 1(javascript client) emit OFFER event it reaches the server and it triggering the offer method on server and from server i will get data from peer 1 and emit the data to peer 2(javascript client) using sio.emit() but the peer 2 does not receiving OFFER event
Client Code
<script> var peersocket = null const socket = io("ws://localhost:8000?id={{ data['id'] }}") const my_per = document.getElementById("my_per") const my_video = document.getElementById("my_video") const remote = document.getElementById("remote") const peer = new RTCPeerConnection(); peer.addEventListener("track",function(e){ console.log("track") remote.srcObject = e.streams[0] }) console.log(navigator.mediaDevices) navigator.mediaDevices.getUserMedia({ video:true, audio:true }).then(stream=>{ my_video.srcObject = stream stream.getTracks().forEach(track=>{ peer.addTrack(track,stream) }) return }).then(_=>{ socket.on("ANSWER",function(data){ console.log("GOT ANSWER") peer.setRemoteDescription(data["answer"]).then(_=>{ console.log("connected") }) }); socket.on("OFFER",function(data){ console.log("GOT OFFER") peersocket = data["from"] peer.setRemoteDescription(data["offer"]).then(_=>{ peer.createAnswer().then(answer=>{ return peer.setLocalDescription(answer) }).then(_=>{ socket.emit("ANSWER",{ "to":peersocket, "answer":peer.localDescription }) }) }) }) socket.on("PEER_JOINED",function(data){ console.log("PEER Joined") peersocket = data["sid"] peer.createOffer().then(offer=>{ return peer.setLocalDescription(offer) }).then(_=>{ return new Promise((resolve,reject)=>{ console.log(peer) console.log("peer.iceConnectionState"+"[front Promise]") if (peer.iceGatheringState == "complete"){ console.log("peer.iceConnectionState"+"[Promise]") resolve() }else{ function statechange(e){ console.log(peer.iceGatheringState) console.log("peer.iceConnectionState"+"[stateChange]") if(peer.iceGatheringState == "complete"){ peer.removeEventListener("icegatheringstatechange",statechange) resolve() } } peer.addEventListener("icegatheringstatechange",statechange) } }) }).then(_=>{ console.log("EMITTING OFFER") socket.emit("OFFER",{ "to":peersocket, "offer":peer.localDescription }) }) }) }).catch(err=>{ console.log(err) }) </script>
Peer 1 output
PEER Joined EMITTING OFFER
Peer 2 output
no output in console
Server code
@sio.on('connect') async def connect(sid,env): interview_id = env["QUERY_STRING"].split("&")[0].split("=")[1] request = sio.get_environ(sid)['aiohttp.request'] session = await get_session(request) user_id = session["id"] clients[user_id] = { "socket":sid, "interview_id":interview_id } result = db["interviews"].find_one({ "_id": ObjectId(interview_id) }) if user_id == str(result["interviewer_id"]): result = clients.get(result["interviewee_id"],0) print("=================") print("im interviewer") print(sid,"my socket id") #print(str(result["socket"]),"interviewee socket id") print("=================") if result != 0: await sio.emit("PEER_JOINED",data={"sid":sid},to=result["socket"]) else: result = clients.get(result["interviewer_id"],0) print("=================") print("im interviewee") print(sid,"my socket id") print(str(result["socket"]),"interviewer socket id") print("=================") if result != 0: await sio.emit("PEER_JOINED",data={"sid":sid},to=result["socket"]) @sio.on("OFFER") async def offers(sid,data): new = { "to":data["to"], "offer":data["offer"], "from":sid } print("OFFER",new["to"]) await sio.emit("OFFER",data=new,to=new["to"]) @sio.on("ANSWER") async def answers(sid,data): await sio.emit("ANSWER",data=data,to=data["to"])
Terminal
**OUTPUT FROM SERVER TERMINAL** ================= im interviewer qBiuTDKXv8f_5s4oAAAD my socket id ================= im interviewee TS3UnfTu8rJiIcdtAAAF my socket id qBiuTDKXv8f_5s4oAAAD interviewer socket id ================= OFFER TS3UnfTu8rJiIcdtAAAF
-
bazel build: failing to link external non-bazel shared library
I am experimenting with Bazel for the first time. I am trying to build a shared library using Bazel-3.7.2. The shared library has an external non-Bazel library dependency. After Bazel build I get the new shared library ".so" file. But using ldd I cannot find the external dependency.
The WORKSPACE file looks as follows. Here libxed.so is the extern shared library.
# xed library new_local_repository( name = "libxed", path = "dependencies/xed/kits/xed-install-base", build_file_content = """ cc_library( name = "libxed", srcs = ["lib/libxed.so"], hdrs = glob([ "include/xed/*.h", ]), visibility = ["//visibility:public"], ) """, ) # xed header files new_local_repository( name = "libxed_headers", path = "dependencies/xed/kits/xed-install-base/include/xed", build_file_content = """ cc_library( name = "xed", hdrs = glob([ "*.h", ]), visibility = ["//visibility:public"], ) """, )
The BUILD file:
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") cc_library( name = "themis", srcs = glob( ["src/main.cpp", "src/tools/Themis/*.cpp", ], ), hdrs = glob([ "includes/tools/Themis/mytool.hpp", ]), strip_include_prefix = "includes", linkopts = ["-pthread", "-lrt", "-lunwind", "-ldl"], deps = [ "@libxed_headers//:xed", "@libxed//:libxed", ], visibility = ["//visibility:public"], )
After building the library it creates libthemis.so.
ldd bazel-bin/libthemis.so linux-vdso.so.1 (0x00007ffe410ab000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f70e7de8000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f70e7a4a000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f70e7842000) libunwind.so.8 => /usr/lib/x86_64-linux-gnu/libunwind.so.8 (0x00007f70e7627000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f70e7423000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f70e7204000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f70e6e13000) /lib64/ld-linux-x86-64.so.2 (0x00007f70e8171000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f70e6bfb000) liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f70e69d5000)
Here libthemis.so does not include libxed.so. Note that I can build the Themis library with Cmake correctly. How can I fix the Bazel build?
-
undefined symbol: _ZTI13my_plugin_api during Boost::DLL tutorial
I have problem running the very first example of Boost::DLL tutorial. At some point I just copied code from the git repo to be sure I didn't do any mistake. Didn't help. Both executable and shared lib compile and link properly. However, I still get the same error when running the program:
terminate called after throwing an instance of 'boost::wrapexcept<boost::system::system_error>' what(): boost::dll::shared_library::load() failed (dlerror system message: ./libmy_plugin_sum.so: undefined symbol: _ZTI13my_plugin_api): Exec format error Interrupt (memory dump)
The funny thing is I don't even have to try to import plugin to get this error... My question is what is happening and why?
My abstract base (in file
my_plugin_api.hpp
):#include <boost/config.hpp> #include <string> class BOOST_SYMBOL_VISIBLE my_plugin_api { public: virtual std::string name() const = 0; virtual float calculate(float x, float y) = 0; virtual ~my_plugin_api(); };
My executable code (file
main.cpp
):#include <boost/dll/import.hpp> // for import_alias #include <iostream> #include "my_plugin_api.hpp" namespace dll = boost::dll; boost::dll::fs::path get_path(char* str) { return boost::dll::fs::path(str); } int main(int argc, char* argv[]) { boost::dll::fs::path lib_path = get_path(argv[1]); // argv[1] contains path to directory with our plugin library boost::shared_ptr<my_plugin_api> plugin; // variable to hold a pointer to plugin variable std::cout << "Loading the plugin" << std::endl; auto multiply = dll::import<double(double, double)>( //importing single function from library lib_path/"my_plugin_sum", "multiply", dll::load_mode::append_decorations ); std::cout << multiply(1.5,1.5) << "\n"; }
Now, the important part, the library code (file
plugin.cpp
):#include <iostream> #include <boost/config.hpp> // for BOOST_SYMBOL_EXPORT #include <boost/dll/alias.hpp> #include "my_plugin_api.hpp" namespace my_namespace { class my_plugin_sum : public my_plugin_api { public: my_plugin_sum() { std::cout << "Constructing my_plugin_sum" << std::endl; } std::string name() const { return "sum"; } float calculate(float x, float y) { return x + y; } ~my_plugin_sum() { std::cout << "Destructing my_plugin_sum ;o)" << std::endl; } }; extern "C" BOOST_SYMBOL_EXPORT my_plugin_sum plugin; my_plugin_sum plugin; } // namespace my_namespace extern "C" { BOOST_SYMBOL_EXPORT double multiply(double x, double y) { return x*y; } }
Additional info:
- System version:
Ubuntu 20.10 (x64)
- Compiler version:
g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0
- Boost version:
1.75.0
- Executable compiled with:
g++ main.cpp -o boost-plugin -ldl -lboost_filesystem
- SO library compiled with:
g++ -shared -fPIC -fvisibility="hidden" -o libmy_plugin_sum.so plugin.cpp
It is enough to remove the following two lines of library code:
extern "C" BOOST_SYMBOL_EXPORT my_plugin_sum plugin; my_plugin_sum plugin;
and error disappears.
Part of result of
nm -C -D libmy_plugin_sum.so
(run on version that generates error):0000000000011510 u guard variable for boost::system::detail::to_std_category(boost::system::error_category const&)::map_ 000000000000a9dc W my_plugin_api::my_plugin_api() 000000000000a9dc W my_plugin_api::my_plugin_api() U my_plugin_api::~my_plugin_api() 000000000000a87c W boost::system::system_error::~system_error() . . . 00000000000ad12 W std::operator==(std::_Rb_tree_iterator<std::pair<boost::system::error_category const* const, std::unique_ptr<boost::system::detail::std_category, std::default_delete<boost::system::detail::std_category> > > > const&, std::_Rb_tree_iterator<std::pair<boost::system::error_category const* const, std::unique_ptr<boost::system::detail::std_category, std::default_delete<boost::system::detail::std_category> > > > const&) U std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) U typeinfo for my_plugin_api 0000000000010ce0 V typeinfo for boost::system::system_error 0000000000010d40 V typeinfo for boost::system::error_category
List of objects of library version that doesn't cause any problems doesn't contain any
my_plugin_api
entry at all.EDIT:
When looking at non-demangled symbols (
nm -D libmy_plugin_sum.so
) I get this:0000000000011510 u _ZGVZN5boost6system6detail15to_std_categoryERKNS0_14error_categoryEE4map_ 000000000000a9e2 W _ZN13my_plugin_apiC1Ev 000000000000a9e2 W _ZN13my_plugin_apiC2Ev U _ZN13my_plugin_apiD2Ev 000000000000a882 W _ZN5boost6system12system_errorD0Ev ... U _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@@GLIBCXX_3.4 U _ZTI13my_plugin_api 0000000000010ce0 V _ZTIN5boost6system12system_errorE ... 000000000000d2a0 V _ZTSN5boost6system6detail22generic_error_categoryE U _ZTV13my_plugin_api U _ZTVN10__cxxabiv117__class_type_infoE@@CXXABI_1.3
- System version:
-
How to Import a registered Phaser3 GameObject from an external library; How to distribute Phaser3 GameObjects
I think my question is "How do I distribute Phaser3 GameObjects in libraries which can be reused".
Here is the issue:
Below, in
Base.js
, is a Base custom GameObject, which I want to be reusable in lots of Phaser3 games.import Phaser from "phaser" export default class Base extends Phaser.GameObjects.Graphics { constructor(scene, x, y) { super(scene, x, y) this.fillStyle(0x770000).fillRect(x, y, 100, 100) } } Phaser.GameObjects.GameObjectFactory.register("base", function (x, y) { const base = new Base(this.scene, x, y) this.displayList.add(base) return base })
This is how I consume the GameObject in a scene. Vanilla stuff.
import Phaser from "phaser" import Base from "@localLibrary/base/lib/Base" // <-- This fails to fire the `register` function. # import Base from "./Base" // <-- This works. export default class PopitScene extends Phaser.Scene { create() { this.add.base(200, 200) } }
When I try to import my GameObject file from a different repo, it fails to fire the
register
function, and the error message I get is:scene.add.base is not a function
In this instance, I have installed the library
npm i file:../base
inside a folder calledgame1
project |- base |- game1 |- game2
And the goal is to have different games reusing the same GameObjects inside the
base
library. -
Presence of risc-v float instructions for the (rv64ima-lp64) soft float compilaton
I compiled glibc 2.33 for risc-v 64-bit(rv64ima-lp64) using the riscv-gnu-toolchain.
The glibc was configured with following flags
./configure --host=riscv64-unknown-linux-gnu --prefix=${PREFIX} --disable-werror --enable-shared --enable-obsolete-rpc --with-headers=${KERNEL_HEADERS} --disable-multilib
And the riscv-gnu-toolchain was configured and compiled with --with-arch=rv64ima and --with-abi=lp64
But on doing
objdump -D ld.so
in elf directory of glibc build, I am getting floating point instructions i.e.83b2e: 317e fld ft2,504(sp) 83b32: 0f00 addi s0,sp,912 83b40: 0014f80f 0x14f80f 83b4c: 0f10 addi a2,sp,912 83b52: 7345 lui t1,0xffff1 83b5a: 0029990f 0x29990f 83b62: 31d2 fld ft3,304(sp) 83b66: 0f20 addi s0,sp,920 83b68: 00000d0f 0xd0f 83b6c: 7645 lui a2,0xffff1 83b6e: f209 bnez a2,83a70 <_end+0x60890> 83b72: 2800 fld fs0,16(s0) 83b74: 0017a00f 0x17a00f 83b80: 0f30 addi a2,sp,920 83b86: 7945 lui s2,0xffff1 83b8c: 3800 fld fs0,48(s0) 83b8e: 0018b00f 0x18b00f 83b96: 325f 0000 3140 0x31400000325f 83ba0: 7b45 lui s6,0xffff1 83bae: 317e fld ft2,504(sp) 83bc8: 04f20803 lb a6,79(tp) # 4f <GLIBC_2.27+0x4f> 83bd2: a300 fsd fs0,0(a4) 83bf2: 000031c7 fmsub.s ft3,ft0,ft0,ft0,rup 83bf6: 00015713 srli a4,sp,0x0 83bfa: 1300 addi s0,sp,416 83bfc: 000004e7 jalr s1,zero # 0 <GLIBC_2.27> 83c0c: a908 fsd fa0,16(a0) 83c10: 3b00 fld fs0,48(a4) 83c50: 3216 fld ft4,352(sp) 83c60: 31f80803 lb a6,799(a6) 83c6a: 3b00 fld fs0,48(a4) 83c80: 2208 fld fa0,0(a2) 83c8a: 325f 0000 6313 0x63130000325f 83caa: 2b18 fld fa4,16(a4)
I am expecting some clarification on this, as the binary should not contain any float instructions.
Thank you.
-
crosscompilation from Linux to old macintosh 68000
I would compiling a C program to old macintosh.
How I can do this today? I would create normal gui program not linux distro on this device. Which compiler working, library for gui etc.
My program is very simple. Hello world. gcc or llvm can do that?
(similar original book, documents https://www.macintoshrepository.org/18756-mac-game-programming but using today tools)
-
cannot compile raspberry kernel on NTFS disk
Sorry for my bad english.
I am trying to compile kernel source code of raspberry and jetson tx2 on a NTFS disk. compile kernel source code of jetson ok, no error. compile kernel source code of raspberry fail with bellow error message:
*** Error during update of the configuration. make[3]: *** [/media/u2004/LINUX_SHARED/rasp/linux/scripts/kconfig/Makefile:39: silentoldconfig] Error 1 make[2]: *** [/media/u2004/LINUX_SHARED/rasp/linux/Makefile:541: silentoldconfig] Error 2 make[1]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/kernel.release'. Stop. make[1]: Leaving directory '/media/u2004/LINUX_SHARED/rasp/build_output' make: *** [Makefile:150: sub-make] Error 2
no error when compile raspberry kernel source code in Ext4 disk.
edit: add compile environment and script cross compile in Ubuntu 20.04 64bit. compile aarch32 with bellow script (compile ok in Ext4 partition).
ROOT_DIR=/home/u2004/Desktop/dm KERNEL_BUILD_DIR=${ROOT_DIR}/linux/ CROSS_COMPILE=${ROOT_DIR}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- BUILD_OUTPUT=${ROOT_DIR}/build_output INSTALL_MOD_PATH_EXT4=${ROOT_DIR}/copy_to_sdcard/ext4 INSTALL_MOD_PATH_FAT32=${ROOT_DIR}/copy_to_sdcard/fat32 ARCH=arm DEF_CONFIG=bcm2709_defconfig TARGET=kernel7 git clone --depth=1 -b rpi-4.9.y https://github.com/raspberrypi/linux git clone https://github.com/raspberrypi/tools export CROSS_COMPILE=${CROSS_COMPILE} cd ${KERNEL_BUILD_DIR} make mrproper make ARCH=${ARCH} O=${BUILD_OUTPUT} ${DEF_CONFIG} make ARCH=${ARCH} O=${BUILD_OUTPUT} -j4 zImage modules dtbs make ARCH=${ARCH} INSTALL_MOD_PATH=${INSTALL_MOD_PATH_EXT4} modules_install
please help. thank you
-
undefined reference error in c++ during compiling
I'm new with template in C++ and I'm puzzled on how I could run my program. The code I'm supposed to do is use a template to "create a static stack of any data type." This is the first time I'm working with templates and I only have a very basic knowledge about it. Hoping to get inputs!
I'm using codio and the code is broken into three files: Main.cpp, Data.h, and Implementation.cpp. The error is this:
/tmp/cckg9fEh.o: In function `main': Main.cpp:(.text+0x24): undefined reference to `IntStack<char>::IntStack(int)' Main.cpp:(.text+0x48): undefined reference to `IntStack<char>::push(char)' Main.cpp:(.text+0x6c): undefined reference to `IntStack<char>::push(char)' Main.cpp:(.text+0x90): undefined reference to `IntStack<char>::push(char)' Main.cpp:(.text+0xb4): undefined reference to `IntStack<char>::push(char)' Main.cpp:(.text+0xd8): undefined reference to `IntStack<char>::push(char)' Main.cpp:(.text+0xfe): undefined reference to `IntStack<char>::pop(char&)' Main.cpp:(.text+0x13b): undefined reference to `IntStack<char>::pop(char&)' Main.cpp:(.text+0x178): undefined reference to `IntStack<char>::pop(char&)' Main.cpp:(.text+0x1b5): undefined reference to `IntStack<char>::pop(char&)' Main.cpp:(.text+0x1f2): undefined reference to `IntStack<char>::pop(char&)' collect2: error: ld returned 1 exit status Stack_Project/test.sh: 6: Stack_Project/test.sh: ./Main.h: not found codio@smile-queen:~/workspace$
My code is as follows:
Data.h
#ifndef INTSTACK_H #define INTSTACK_H #include <iostream> #pragma once template <class T> class IntStack { private: T *stackArray; int stackSize; int top; public: IntStack(int size); void push(T let); void pop(T &let); bool isFull(); bool isEmpty(); }; #endif
Implementation.cpp
#include <iostream> #include "Data.h" using namespace std; template <class T> IntStack<T>::IntStack(int size) { stackArray = new T[size]; stackSize = size; top = -1; } template <class T> void IntStack<T>::push(T let) { if (isFull()) { cout << "The stack is full.\n"; } else { top++; stackArray[top] = let; } } template <class T> void IntStack<T>::pop(T &let) { if (isEmpty()) { cout << "The stack is empty.\n"; } else { let = stackArray[top]; top--; } } template <class T> bool IntStack<T>::isFull() { bool status; if (top == stackSize - 1) status = true; else status = false; return status; } template <class T> bool IntStack<T>::isEmpty() { bool status; if (top == -1) status = true; else status = false; return status; }
Main.cpp
#include <iostream> #include "Data.h" using namespace std; int main() { IntStack<char> stack(5); char reclaim; cout << "Pushing M\n"; stack.push('M'); cout << "Pushing C\n"; stack.push('C'); cout << "Pushing P\n"; stack.push('P'); cout << "Pushing U\n"; stack.push('U'); cout << "Pushing D \n"; stack.push('D'); cout << "Popping...\n"; stack.pop(reclaim); cout << reclaim << endl; stack.pop(reclaim); cout << reclaim << endl; stack.pop(reclaim); cout << reclaim << endl; stack.pop(reclaim); cout << reclaim << endl; stack.pop(reclaim); cout << reclaim << endl; }
Thanks for the help!
-
undefined reference when including a header-file
I try to code a Checkers game.
To make it easier to read, I wanted to split it into several files, but I get an "undefined reference" error. So far, I have a
main.cpp
, aBoard.cpp
and aBoard.hpp
. It works, when its all inmain.cpp
, but once I split it up, and include the board header file, I get the error.I have done this before, and it looks just like how I've done it before, so I don't know why it's acting up now.
main.cpp
#include <iostream> #include <array> #include <cmath> #include "Board.hpp" class Gameplay { protected: std::array<std::array<char,8>,8> gameboard; // Board with tokens on it public: //.... //Beginning Set-Up void setup (); /... friend class Board; }; //SetUp void Gameplay::setup () { char user1 = '@'; //Symbol of User 1 char user2 = 'c'; Board plainBoard; //board with no tokens //These two lines is when I get the undefined plainBoard.create(); //reference error gameboard = plainBoard.board; //... }
Board.hpp
#ifndef BOARD_HPP_INCLUDED #define BOARD_HPP_INCLUDED #endif // RECHNER_HPP_INCLUDED #include <iostream> #include <array> class Board { protected: std::array<std::array<char,8>,8> board; //Plain Board public: //.... friend class Gameplay; };
board.cpp
#include <iostream> #include <array> #include <cmath> #include "Board.hpp" //...
The code works, I just get the
#include
part wrong. Errors: undefined reference to 'Board::create()' undefined reference to 'Board::~Board()' -
Undefined reference to signalr::value::as_string()
It is about compiling the sample project of the SignalR-Client-Cpp Here.
The Libs was generated using 32 bits in SUSE Linux Enterprise Server 12 (x86_64) with GCC 7.5.0.
The error occuered by linking
g++ -g -m32 -z muldefs -lz -L/home/ihil/SignalR-Client-Cpp/build.release/bin/ -lsignalrclient -o "SignalrBetaClient" HubConnectionSample.o; HubConnectionSample.o: In Funktion »std::_Function_handler<void (signalr::value const&), chat()::{lambda(signalr::value const&)#1}>::_M_invoke(std::_Any_data const&, signalr::value const&)«: HubConnectionSample.cpp:(.text+0x284): Warnung: undefinierter Verweis auf »signalr::value::as_string() const« HubConnectionSample.o: In Funktion »std::_Function_handler<void (signalr::value const&, std::__exception_ptr::exception_ptr), send_message(signalr::hub_connection&, std::string const&)::{lambda(signalr::value const&, std::__exception_ptr::exception_ptr)#1}>::_M_invoke(std::_Any_data const&, signalr::value const&, std::__exception_ptr::exception_ptr)«: HubConnectionSample.cpp:(.text+0x41c): Warnung: undefinierter Verweis auf »signalr::value::as_string() const« HubConnectionSample.o: In Funktion »send_message(signalr::hub_connection&, std::string const&)«: HubConnectionSample.cpp:(.text+0x5b9): Warnung: undefinierter Verweis auf »signalr::value::value(std::string&&)« HubConnectionSample.cpp:(.text+0x5d4): Warnung: undefinierter Verweis auf »signalr::value::value(std::string const&)« HubConnectionSample.cpp:(.text+0x6d3): Warnung: undefinierter Verweis auf »signalr::hub_connection::invoke(std::string const&, signalr::value const&, std::function<void (signalr::value const&, std::__exception_ptr::exception_ptr)>)« HubConnectionSample.o: In Funktion »chat()«: HubConnectionSample.cpp:(.text+0xcad): Warnung: undefinierter Verweis auf »signalr::hub_connection_builder::create(std::string const&)« HubConnectionSample.cpp:(.text+0xd94): Warnung: undefinierter Verweis auf »signalr::hub_connection::on(std::string const&, std::function<void (signalr::value const&)> const&)« collect2: Fehler: ld gab 1 als Ende-Status zurück
Although the list of symbles of the library shows that the undifined references are found
nm -a bin/libsignalrclient.so | grep 'hub_connection_builder' 00000000 a hub_connection_builder.cpp 00030b70 T _ZN7signalr22hub_connection_builder12with_loggingESt10shared_ptrINS_10log_writerEENS_11trace_levelE 00030d60 T _ZN7signalr22hub_connection_builder16with_http_clientESt10shared_ptrINS_11http_clientEE 00030ca0 T _ZN7signalr22hub_connection_builder22with_websocket_factoryESt8functionIFSt10shared_ptrINS_16websocket_clientEERKNS_21signalr_client_configEEE 00030e80 T _ZN7signalr22hub_connection_builder5buildEv 00030530 T _ZN7signalr22hub_connection_builder6createERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE 00030700 T _ZN7signalr22hub_connection_builderaSEOS0_ 00030890 T _ZN7signalr22hub_connection_builderaSERKS0_ 00030660 T _ZN7signalr22hub_connection_builderC1EOS0_ 00030460 T _ZN7signalr22hub_connection_builderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE 00030560 T _ZN7signalr22hub_connection_builderC1ERKS0_ 00030660 T _ZN7signalr22hub_connection_builderC2EOS0_ 00030460 T _ZN7signalr22hub_connection_builderC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE 00030560 T _ZN7signalr22hub_connection_builderC2ERKS0_ 000309c0 T _ZN7signalr22hub_connection_builderD1Ev 000309c0 T _ZN7signalr22hub_connection_builderD2Ev