iotovity croos compilation fails. - arm

Greetings
I am new to iotivity and following the iotivity wiki guidelines for understanding and building framework.(on Ubuntu 16.04)
AIM - For ARM Cross Compilation. We are following the below Iotivity link.
https://wiki.iotivity.org/iotivity_porting_to_arm_based_platforms?s[]=arm&s[]=based&s[]=platforms
Described below Step 4 as mention in the link .
We are using arm-linux-gnueabi compiler which support build for our tager Artik 520 - ARM Cortex A7 processer.
4) Download the UUID Header/Libraries for arm architecture from Internet or from linkuuid-arm.zip. Place the UUID Headers/Libraries inside IoTivity folder (For Eg: iotivity/extlibs/). Update the CPPPATH/LIBPATH for UUID Headers/Libraries in required SConscript
As describe above i have followed the steps.
-Issue is the uuid-arm folder doesn't have any defulat SConscript when unzip(only header and lib folder) and it is not Cleary mention which is the required SConscript to add below lines. The uuid.so is present in the uuid-arm lib folder.below are the lines which are mention need to be added.i am confused on this which will be the required Sconscripts and how to debug this. Kindly help on this.
For E.g.: env.AppendUnique(CPPPATH = [ '<uuid header path>'])
env.AppendUnique(LIBPATH = ['<uuid Library Path>'])
env.AppendUnique(LIBS = ['uuid'])
{{:arm_uuid_path.png?200|}} -----> This line itself is a syntax error to add anywhere.
Build Command
scons TARGET_OS=linux TARGET_ARCH=arm TARGET_TRANSPORT=IP SECURED=0 RELEASE=1 TC_PREFIX=arm-linux-gnueabi- TC_PATH=/usr/arm-linux-gnueabi/bin
ERROR
scons: Building targets ...
scons: building associated VariantDir targets: out/linux/arm/release Linking out/linux/arm/release/resource/csdk/connectivity/src/libconnectivity_abstraction.so
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: cannot find -luuid
collect2: error: ld returned 1 exit status
scons: *** [out/linux/arm/release/resource/csdk/connectivity/src/libconnectivity_abstraction.so] Error 1
scons: building terminated because of errors
Thanks for help..

From the error message, it looks like the path to the uuid library is not updated properly in the scons file.
Can you please share your changes in the scons file, specifically the below lines.
env.AppendUnique(CPPPATH = [ '<uuid header path>'])
env.AppendUnique(LIBPATH = ['<uuid Library Path>'])
env.AppendUnique(LIBS = ['uuid'])
I hope you have updated the ['< uuid Library path>'] with your absolute path, which may be /root/workspace/iotivity/extlibs/uuid
Agreed, {{:arm_uuid_path.png?200|}} is not a proper scons syntax. It looks like a webpage error to me, instead of the image file, just the path is included

Related

arm toolchain does not seem to have C libraries

I am trying to cross compile a simple program with the arm toolchain. And stdio library points to another library, which results in the following error:
/home/sansari/tools/arm-eabi-4.7/bin/arm-eabi-gcc hello.c -o hello
In file included from hello.c:3:0:
/home/sansari/tools/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/include-fixed/stdio.h:50:23: fatal error: sys/cdefs.h: No such file or directory
compilation terminated.
make: *** [hello] Error 1
At first, I thought this file is in some subdirectory of the toolchain, and I need to include the folder for this library in my makefile. But a quick tree output says that it is not. So given that I have used this toolchain successfully for a larger project, I know it is copied from somewhere. So my question is how do I add it to this project please? And what is the appropriate place to copy it from? I am trying to understand why it is not in the toolchain folders that I have, and how I should add it to my project please.
#Olaf - You have been very helpful; I however have a little more learning curve. But I do understand what you are instructing. I know I have the libraries in my build system since have built for this platform successfully. I even know that it is in my WORKING_DIRECTORY. What I do not know is if I can copy a folder and address the issue entirely or do I need to keep compiling and see what errors I get. That is do it incrementally. For example, one of the files, which was missing was cdefs.h. And I was able to find it in the folder:
/home/sansari/ndk/android-ndk-r10d/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h
So I copied it over and the build process proceeded to the next stage. I do like to know if I should perhaps have copied the entire /sys or /include directory or compared the /include directory of my source and make sure all the files are also in the destination directory also. And that way I can avoid having to compile a number of times.
But nevertheless, I proceeded with copying one file at a time. The last error I got is:
/home/sansari/tbt/tools/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/include/stdint.h:3:26: fatal error: stdint.h: No such file or directory
And I look in the include directory; I see a file call stdint.h
What do you make of that? Does that make sense to you? I am confused by this error. How can I get this error when the file is in the directory. Basically it seems make is saying this file does not exist when it does.
I did find This post also, which seems to say what you are saying. I just need to know what is the best way to address it.
#Olaf - I really appreciate all your help. I was able to get through all the library errors by putting an include statement in my makefile. Now the linker is giving me errors as follows:
/home/sansari/tbt/tools/arm-eabi-4.7/bin/arm-eabi-gcc -I../../ndk/android-ndk-r10d/platforms/android-19/arch-arm/usr/include hello.c -o hello
/home/sansari/tbt/tools/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/../../../../arm-eabi/bin/ld: cannot find crt0.o: No such file or directory
/home/sansari/tbt/tools/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/../../../../arm-eabi/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make: *** [hello] Error 1
update - I searched for a solution for the above errors. The first error is discussed here and -nostartfiles switch seems to work for me for now. I found this link that talks about libc.a being the fix for the error about not finding -lc. So I found an appropriate copy of libc.a and passed the location to the linker. The program compiles, but I get one last warning as follows:
warning: cannot find entry symbol _start; defaulting to 00000000000080dc
For which this link suggested using --entery-main switch. So now I have an executable. I want to thank you again. If you do see any problem in what I have done, please post something for me. it is gonna take a while for me to get this executable on my device.

PLplot linker error

I am trying to use PLplot for visualization in a C project.
However, although the headers and the libraries seem to be correctly included (cmake returns no error), when I try to actually use some PLplot functions, I get errors similar to undefined reference to 'c_plinit' and ld returned 1 exit status
I guess it is a linker problem and it seems like a common problem. However, the stuff I found on google are either not applicable for my case or not detailed enough for a beginner like me.
Note that if I add in the CMakeLists.txt:
message(${PLplot_INCLUDE_DIRS})
message(${PLplot_LIBRARY_DIRS})
message(${PLplot_LIBRARIES})
I get the following output:
/usr/local/include/plplot
/usr/local/lib
/usr/local/lib/libplplotcxxd.so
Please help!
EDIT:
The relevant lines from CMakeLists.txt are as follows:
# The directory with the FindPLplot module
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
FIND_PACKAGE(PLplot REQUIRED)
SET(PLplot_LIBRARIES ${PLplot_LIBRARIES} ${PLplot_cxx_LIBRARY})
INCLUDE_DIRECTORIES(${PLplot_INCLUDE_DIRS})
LINK_DIRECTORIES(${PLplot_LIBRARY_DIRS})
ADD_EXECUTABLE(main main.c)
TARGET_LINK_LIBRARIES(main ${PLplot_LIBRARIES})
INSTALL(TARGETS main DESTINATION bin)
And then, under a folder called cmake, there is a FindPLplot.cmake module similar to the one here: https://github.com/mrquincle/polychronization/blob/master/cmake/

Mingw and Eclipse unable to find library - 2

I am faced with the exact same situation as the question raised by Gustavo in the following Link. Also, I have tried all the solutions posted in that link and other tags (such as changing library names from opus.a to libopus.a, change '\' to '/' and so on) but none of these have solved my problem. By opening the properties of the library file, these are the following things displayed:
Path: /demo/opusfile/libopusfile.a
Type: File (Static Library)
Location: U:\data\Jag\eclipse\wrksp\demo\opusfile\libopusfile.a
The error message displayed by Mingw is as follows:
15:56:57 **** Incremental Build of configuration Debug for project demo ****
Info: Internal Builder is used for build
gcc -o demo.exe "src\\demo.o" -lU:/data/Jag/eclipse/wrksp/demo/opusfile/libopusfile.a
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lU:/data/Jag/eclipse/wrksp/demo/opusfile/libopusfile.a
collect2.exe: error: ld returned 1 exit status
collect2.exe: error: ld returned 1 exit status
Could someone please let me know what am I missing ? I am not able to resolve this issue
I think I found the solution, thanks to the answer posted in this Link. So basically to summarize the solution, I had to remove the 'lib' prefix, the '.a' suffix and the library path when I specified the libraries (-l parameters). The library path has to be specified in the -L parameter . This resolved the above problem but led to another hurdle by Mingw:
libopusfile.dll.a: could not read symbols: Archive has no index; run ranlib to add one.
I executed the 'ranlib' command in the command prompt
cmd_path> ranlib libopusfile.dll.a
, as suggested by the compiler, and this solved all my issues!

CMakeLists.txt configuration - simple but stuck - library not been added to generated project

I was originally following this tutorial: http://www.opengl-tutorial.org/miscellaneous/building-your-own-c-application/
just after about half way down, from where it says "Adding a source file in a project"
I created from this my CMakeLists.txt file as so:
cmake_minimum_required (VERSION 2.6)
project (Cube_Project)
find_package(OpenGL REQUIRED)
add_executable(Cube
main.cpp
)
include_directories(
external/glfw-2.7.6/include/
external/glm-0.9.4.0/
external/glew-1.9.0/include/
.
)
set(ALL_LIBS
${OPENGL_LIBRARY}
GLFW_276
GLEW_190
)
target_link_libraries(Cube
${ALL_LIBS}
)
but when I generate the project, I get this error:
ld: library not found for -lGLFW_276
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?
I think maybe I'm not using the right names in the set(....) section? My three libs are in a folder called external, which is the top level of the project (i.e. CMakeLists is also here).
I put a zip of the project if anyone wants to take a look at the folder layout of output XCode project structure: http://heather.sh/OpenGL_Project.zip
Thanks,
The library is not in the linker's library search path.
The target_link_libraries command is is very straightforward: It simply passes on all of its arguments to the linker without bothering whether any of those libraries actually exist.
In your case, the GLFW_276 library is missing (and possibly the GLEW_190 as well, since the error occurs before that one is being processed). Make sure the library is actually installed on your system and its filename actually matches the name you use here (eg. libGLFW_276.so).
Once you verify that you have the required file, you need to make sure that the linker is able to find it. If the file is not located in one of the standard directories, use either link_directories to add its location to the search path, or find_library to obtain the full path to the library file, which can then be given to target_link_libraries.

How do you export a system library using cmake?

How can I export the libraries that a cmake library depends on, such that an executable depending on that library does not have to manually depend on the dependencies of that library?
That's a bit of a mouthful, so here's an example:
dummy (application) ----> depends on liba
liba ----> depends on libpng
Compiling dummy generates errors:
-- Found LIBPNG
-- Found LIBA
-- Configuring done
-- Generating done
-- Build files have been written to: /home/doug/projects/dummy/build
Linking C executable dummy
../deps/liba/build/liba.a(a.c.o): In function `a_dummy':
/home/doug/projects/dummy/deps/liba/src/a.c:6: undefined reference to `png_sig_cmp'
collect2: ld returned 1 exit status
make[2]: *** [dummy] Error 1
make[1]: *** [CMakeFiles/dummy.dir/all] Error 2
make: *** [all] Error 2
I can fix that by adding this into CMakeLists.txt for dummy:
TARGET_LINK_LIBRARIES(dummy png)
However, dummy has no knowledge of how liba implements its api. At some point that may change to being libjpg, or something else, which will break the dummy application.
After getting some help from the cmake mailing list I've been directed to this example for exporting things:
http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
However, following that approach leaves me stuck at this line:
export(TARGETS ${LIBPNG_LIBRARY} FILE "${PROJECT_BINARY_DIR}/ALibraryDepends.cmake")
Clearly I'm missing something here; this 'export' command looks like its designed to export sub-projects to a high level; ie. nested projects inside liba.
However, that is not the problem here.
When configuring liba (or any cmake library) I will always generate a list of dependencies which are not part of that project.
How can I export those so they appear as part of LIBA_LIBRARY when I use find_package() to resolve liba?
Using static libraries is not an option (static library for something that links to opengl? no.)
Given your comment to arrowdodger's answer about the fear of
installing something would mess up your system I chose to give
a conceptional comment in form of an answer because of its
length.
Chaining cmake project works via find_package, which looks for
*Config.cmake and *-config.cmake files.
Project A's CMakeLists.txt:
#CMakeLists.txt
project(A)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/AConfig.cmake share/A/cmake
)
#AConfig.cmake
message("Yepp, you've found me.")
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/tmp/test-install ..
$ make install
Project B's CMakeLists.txt:
project(B)
find_package(A)
Then
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/tmp/test-install ..
$ make install
results in
...
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Yepp, you've found me.
B found A because it installed AConfig.cmake into a location
where cmake will find it 'share/A/cmake' AND was given the same
value for CMAKE_INSTALL_PREFIX.
Now this is that. Lets think about what you can do in
AConfig.cmake: AFAIK everything you want to. But the most common
task is to pull information about the targets of A via include(),
do some additional find_package invoctions for 3rd party
packages (HINT HINT) and create the variables
A_LIBRARIES
A_INCLUDE_DIRS
What you want to include is a file that was created by
install(EXPORT A-targets
DESTINATION share/A/cmake
)
in A's CMakeLists.txt , where A-targets refers to a global cmake
variable that accumulated all target informations when used in
install(TARGETS ...
EXPORT A-targets
...
)
statments. What is created at make install is
/tmp/test-install/share/A/cmake/A-targets.cmake
which then resides alongside AConfig.cmake in the same directory.
Please take another look at the wiki page on how to use this file
within AConfig.cmake.
Regarding the export() command: This comes handy if your
projects have gotten HUGE and it takes a considerable amount of
time to install them. To speed things up, you want to use what's
in A's build/ directory directly. It's an optimization and also
explained in the wiki. It still works via find_package(), see
http://cmake.org/cmake/help/cmake-2-8-docs.html#command:export
But I strongly suggest that you go for the usual make install
route for now.
I found my own solution to this problem using the accepted solution above, which I leave here for others:
In liba/CMakeLists.txt:
# Self
set(A_INCLUDE_DIRS ${A_INCLUDE_DIRS} "${PROJECT_SOURCE_DIR}/include")
set(A_LIBRARIES ${A_LIBRARIES} "${PROJECT_BINARY_DIR}/liba.a")
# Libpng
FIND_PACKAGE(libpng REQUIRED)
set(A_INCLUDE_DIRS ${A_INCLUDE_DIRS} ${LIBPNG_INCLUDE_DIRS})
set(A_LIBRARIES ${A_LIBRARIES} ${LIBPNG_LIBRARIES})
ADD_LIBRARY(a ${SOURCES})
# Includes
INCLUDE_DIRECTORIES(${A_INCLUDE_DIRS})
# Allow other projects to use this
configure_file(AConfig.cmake.in "${PROJECT_BINARY_DIR}/AConfig.cmake")
In liba/AConfig.cmake:
set(A_LIBRARIES #A_LIBRARIES#)
set(A_INCLUDE_DIRS #A_INCLUDE_DIRS#)
In dummy/CMakeLists.txt:
FIND_PACKAGE(A REQUIRED)
INCLUDE_DIRECTORIES(${A_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(dummy ${A_LIBRARIES})
This yields an AConfig.cmake that reads:
set(A_LIBRARIES /home/doug/projects/dummy/deps/liba/build/liba.a;/usr/lib/libpng.so)
set(A_INCLUDE_DIRS /home/doug/projects/dummy/deps/liba/include;/usr/include)
And a verbose compile that reads:
/usr/bin/gcc -std=c99 -g CMakeFiles/dummy.dir/src/main.c.o -o dummy -rdynamic ../deps/liba/build/liba.a -lpng
Which is exactly what I was looking for.
If liba doesn't provide any means to determine it's dependencies, you can't do anything.
If liba is library developed by you and you are using CMake to build it, then you should install libaConfig.cmake file with liba itself, which would contain necessary definitions. Then you include libaConfig in dummy's CMakeLists.txt to obtain information about how liba have been built.
You can look how it's done in LLVM project, relevant files have cmake.in extension
http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/
In the end, in dummy project you should use
target_link_libraries( ${LIBA_LIBRARIES} )
include_directories( ${LIBA_INCLUDE_DIR} )
link_directories( ${LIBA_LIBRARY_DIR} )
If that liba is used only by dummy, you can build it from single CMake project. This is more convenient, since you don't need to install liba each time you recompile it and it will be rebuilt and relinked with dummy automatically every time you run make.
If you liked this approach, the only thing you should do - define in liba' CMakeLists.txt variables you need with PARENT_SCOPE option (see set() command manual).
Finally, you can use shared libs, .so's don't have such problem.

Resources