I have a problem with PCL: specifically I want to use it in the existing project with existing Makefiles. However, PCL is using CMake and I couldn't find how to add it to Makefile directly. Does anyone know how to do that?
First try to compile the one of the example provided in PCL website using CMake.
http://pointclouds.org/documentation/tutorials/pcl_visualizer.php
After compiling the above example, you will find various new files and a folder created by CMake in your directory.
Go to CMakeFiles/pcl_visualizer_demo.dir/ .
Open file named link.txt, which contains the terminal command which has various pcl(point cloud libraries) linked dynamically to the file.
command should look similar to the command shown below
/usr/bin/c++ -O3 -Wno-deprecated -s CMakeFiles/pcl_visualizer_demo.dir -o pcl_visualizer_demo -rdynamic -lpcl_common -Wl,-Bstatic -lflann_cpp_s -Wl,-Bdynamic -lpcl_kdtree -lpcl_octree -lpcl_search -lqhull -lpcl_surface -lpcl_sample_consensus -lpcl_io -lpcl_filters -lpcl_features -lpcl_keypoints -lpcl_registration -lpcl_segmentation -lpcl_recognition -lpcl_visualization -lpcl_people -lpcl_outofcore -lpcl_tracking /usr/lib/libvtkGenericFiltering.so.5.8.0 /usr/lib/libvtkGeovis.so.5.8.0 /usr/lib/libvtkCharts.so.5.8.0 /usr/lib/libvtkViews.so.5.8.0 /usr/lib/libvtkInfovis.so.5.8.0 /usr/lib/libvtkWidgets.so.5.8.0
You can include these libraries in your Makefile directly.
If you use different functions or pcl headers files, then first try compiling it using CMake and get the libraries linked and add it to your Makefile of previous project.
I tried this method for my project which worked perfectly fine. I tried pkg-config to link the libraries, which didn't work in my case. I was not able to find any other method that easily links all the required libraries.
Related
I have a CortexM0 project using a custom Makefile that builds and debugs successfully on a 1st machine.
Now trying to move the project to a second Mac.
Same version of Eclipse.
On build I get a linker error:
EclipseApr2019/gcc-arm-none-eabi-5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld: cannot find -lg
My make file looks like this (extract):
# echo "path="$(TOOLS)
$(TOOLS)arm-none-eabi-gcc -n -v -mcpu=cortex-m0 -mthumb -g -nostartfiles -T STM32F031C6_simple.ld main.c StartUp_simple.s -o $(NAME).elf
I have tried to append the ARM gcc tools directory to the PATH variable in the Project, but no luck.
I would add a -l option to the link stage in the makefile, but do not know why this library is being pulled in or where it is. My code only does a series of shifts and reads/writes to registers on an MCU. The build on the 1st machine worked fine without specifying a library location like this.
Given I have custom makefile and am not generating Makefile automatically, there are no tool settings (and Library search path) available under Properties/CC++Build/Settings.
What is library "g" that the linker is pulling in?
Where is it?
Under Eclipse, how can I point the linker to the library?
Why didn't I need to do that before?
What is some general advice for designing an Eclipse project with a custom makefile to make it most portable between machines?
Thank you.
Eclipse IDE for C/C++ Developers
Version: 2019-03 (4.11.0)
I am using dev c++ IDE which used ming gcc(i am not sure of it)
I wanted to use sqlite3 in my win32 c application
I downloaded sqlite3.dll and sqlite3.dev and used dlltool to create a .a file like libsqlite3.a and pasted in the lib folder of dev cpp and added this path in the project options -> parameters
i copied the header file sqlite3.h into the include folder(which i got from another website - http://www.opensource.apple.com/source/SQLite/SQLite-74/derived_source/sqlite3.h)
i executed the program and got the message 'the program can't start because sqlite3.dll is missing in your computer'
so i copied the sqlite3.dll into my working directory and then it worked
BUT
How to make the sqlite.* static while compiling?
I mean i thought by including the libsqlite3.a, the final exe will not be dependent of any external dll's.
So i want to know how to compile in a way that i will not be needing a dll and by doing so it makes my windows program standalone.
do i have a create a .lib file instead of .a file?
EDIT after answers and comments:
Besides, the devpak is working fine... yet i wanted to know how to include files to project or to create .a files so i am trying this way because if some components do not provide devpak then this will be the way we need to compile.. isn't it?
EDIT to show what i have done after the answer by CL and the two comments
This is how i have added the sqlite.c to project list
Here is the compile log
Compiler: Default compiler
Building Makefile:
"C:\Users\jayapalc\Documents\test-sqlite\Makefile.win"
Executing make...
make.exe -f "C:\Users\jayapalc\Documents\test-sqlite\Makefile.win" all
g++.exe -c sqlite3.c -o sqlite3.o -I"lib/gcc/mingw32/3.4.2/include"
-I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
sqlite3.c: In function `void strftimeFunc(sqlite3_context*, int,
sqlite3_value**)':
sqlite3.c:14727: error: invalid conversion from void*' tochar*'
The files i got in sqlite.org/sqlite-amalgamation-3071502.zip are
shell.c, sqlite3.h, sqlite3.c, sqlite3ext.h and i saw in other discussions that shell.c is not needed...
Besides, people were talking about gcc and g++... .
Apart from updating Dev-C++ itself, try this to compile sqlite.c as a C file:
Go to Project >> Project Options >> Files.
Find the C file we're talking about. Untick "Compile file as C++".
This should inform Dev-C++ that it should invoke gcc.exe, and not g++.exe.
If you don't want to compile sqlite yourself by adding it to your project, you can try passing the -static flag to GCC/G++ to force it to link libsqlite.a statically.
Just include the sqlite3.c file in your project.
You need only this filed, and it must be compiled as C, not C++.
Apparently, Dev-C++ does not allow mixing C and C++ source files in one project.
Instead, you could try to compile sqlite3.c as C and then include the generated .o file into the C++ project (on the Linker page).
I have an Autogen Makefile.am that I'm trying to use to build a test program for a shared library. To build my test binary, I want to continue building the shared library as target but I want the test program to be linked statically. I've spent the last few hours trying to craft my Makefile.am to get it to do this.
I've tried explicitly changing the LDADD line to use the .a version of the library and get a file not found error even though I can see this library is getting built.
I try to add the .libs directory to my link path via LDFLAGS and still it can't find it.
I tried moving my library sources to my test SOURCES list and this won't work because executable object files are built differently than those for static libraries.
I even tried replicating a lib_LIBRARIES entry for the .a version (so there's both a lib_LTLIBRARIES and a lib_LIBRARIES) and replicate all the LDFLAGS, SOURCES, dir and HEADERS for the shared version as part of the static version (replacing la with a of the form _a_SOURCES = _la_SOURCES. Still that doesn't work because now it can't figure out what to build.
My configure.ac file is using the default LT_INIT which should give me both static and dynamic libraries and as I said it is apprently building both even if the libtool can't see the .a file.
Please, anyone know how to do this?
As #Brett Hale mentions in his comment, you should tell Makefile.am that you want the program to be statically linked.
To achieve this you must append -static to your LDFLAGS.
Changing the LDFLAGS for a specific binary is achieved by changing binary_LDFLAGS (where binary is the name of the binary you want to build).
so something like this should do the trick:
binary_LDFLAGS = $(AM_LDFLAGS) -static
My main aim is to get the GSL Shell working on my OSX 10.7 system. So far I have the correct version of lua with the correct patches running. I also have a working version of GSL which compiles and runs example programs. I can build agg perfectly and also run their example programs by running make in the macosx_sdl folder.
My first question is how on earth do I create my own project with agg? I know that you are supposed to simply add the files to your project file and go, but this does not seem to want to compile for me. Is it simply a case of adding the include directory and the libagg.a?
Finally, how do I build gsl shell? Currently it complains about the agg-plot folder a lot, so where do I put the agg files to make this build, then when i've done it where do I place the agg files so that the lua scripts can get to them?!
Hope someone can help!
In general to use the AGG library you need to make sure that the compiler is able to find the headers files and, during the linking, the libraries, either in form of a static or dynamic libraries.
To make the headers files and the libraries available you need to take into account the system that is used to build the software. If a traditional makefile sistem is used you need to add some flags to make sure that the headers file can be found. This can be achieved by adding into the makefile something like:
CFLAGS += -I/path/to/agg/headers
and for the linker:
LIBS += -L/path/to/agg/library -lagg -lm
In the specific case of GSL Shell 1.1 the file "make-packages" is used in the Makefile to configure the required packages. You can add here the flags required to locate the AGG library:
AGG_INCLUDES = -I/usr/include/agg2
AGG_LIBS = -lagg -lX11 -lpthread -lsupc++
you should just modify the path provided with the "-I" option and, in AGG_LIBS, add an option "-L/path/to/agg/library" to specify the path where the AGG libraries are located.
Please note also that the agg libraries depends on other libraries. For example on linux it needs at least the X11 library. The libraries supc++ may be needed if the linking is made by invoking gcc instead of g++ because if gcc is used the C++ runtime libraries are not included.
I have an Objective-C/Cocoa project that incorporates a static library. That static library has some object files that have C++ in them.
I've found that if the project that I'm using the library in contains no other C++ in it, the link fails (can't link new/delete/etc). But simply adding a single (empty) .cpp file to the project causes the link to succeed.
In practice, what happens is that the build will invoke g++ instead of gcc when there is any cpp, which succeeds. No other difference in the build is apparent to me.
Is there an explicit switch I can use to link in this library without using the dummy cpp file in the project?
(This is mostly a curiosity question-- it's not the end of the world to put in one empty file. :) )
Thanks.
try to link libstdc++
gcc main.c -lstdc++
or in Xcode:
Project->Edit Project Settings
To the config section "Other Linker Flags", add -lstdc++.