I am building a C++ application in Xcode 5 that links to external dynamic libraries (OpenCV 2.4.6, installed via macports). These dynamic libraries appear to have been compiled without debugging symbols, since, when I hit an error in them, I can't see the source code; all I see is assembly code.
I have separately downloaded the OpenCV source code from the OpenCV web site. Is there a way for me to tell Xcode where to look for the source files for the dylibs so that I can step through the OpenCV code in the Xcode debugger?
No, this isn't possible. When a library is compiled with debugging support, additional data is bundled into the shared library which contains a mapping along the lines of "address 0x00240008 corresponds to main.c:24", "address 0x0024001a corresponds to main.c:25", etc. If the modules were built without debugging support, the files are now simply binary blobs that contain machine code and the debugger has no way to translate the machine language back into the source code.
However, since you have the source code, you can recompile the library to include that information and install your custom version. For OpenCV, this will be a command like this:
cmake -DCMAKE_BUILD_TYPE:=Debug .
Related
Here's my problem:
Trying to debug a C++ program in gdb, but bt won't produce a complete backtrace. It's getting stuck on the Glib shared library, which has been built without any debug info and without -frecord-gcc-switches - this is how it comes as part of the o/s.
I want to build the shared library exactly the same, but with debug info. How can I do this? Building it with Meson shows several other shared libraries and packages that will influence its contents depending on their presence, and there's also of course different compile time flags I can use.
Is there an easy way to ensure the version I build from source produces the same object file as that packaged with linux (plus debug info)?
I've used apt-get source glib2.0-0 and it gives me all the meson files, ninja files and help files I appear to need, but it doesnt quite say this is how it comes as part of Raspberry Pi O/S.
I am following a tutorial that takes me to this SDL page (https://www.libsdl.org/download-2.0.php). In there, I can see three things I can download:
Source code
Runtime Binaries
Development libraries
I am trying to make sense out of them. My understanding is this:
Source Code: Is the original code made by the creator of the SDL, not compiled into a library.
Runtime Binaries: I have no idea
Development libraries: Is the code but this time compiled into libraries. There are two versions because one was compiled in a way that works with the VC (Visual compiler) and the other one is compiled in a way that works with the gcc compiler.
What are the runtime binaries for?
I imagine these thee scenarios:
Source Code: I am writing my project and when I hit compile I compie what I wrote alone with the SDL source code.
Runtime binaries: ?
Development libraries: I set up my programming environment to recognize the libraries. Then I write my code and when I hit compile the compiler compiles my code and then the linker links my code and the SDL libraries together into an executable.
The runtime binaries / libraries are the files that your application needs to use at run-time to access the library functions. They are the files that contain the actual compiled code of the library that your application will call when it is executed.
When we build the opencv library, either in a dynamic way or in a static way, we will produce several separated libraries. Take the 2.48 version for example, we will have
opencv_core248 opencv_imgproc248 zlib IlmImf comctl32 opencv_highgui248 libpng
and so on. So my question here is clearly there are some dependencies between these libraries, for example, if I want to invoke opencv_core248 and opencv_imgproc24 library in a project, I have link errors. Then, if I add zlib library, the compilation error will be solved.
Question: I want to ask a very general question: how can I know the dependencies between all the libraries insider opencv? Are there some documents I can follow? Thanks.
I don't think there is a document listing all the dependencies between the OpenCV libraries.
However I can suggest two methods to find out these dependencies:
Using Dependency Walker, a free tool allowing to analyze executables and DLLs. For instance, if you open opencv_calib3dXXX.DLL (where XXX represents your OpenCV version), you'll see that it requires opencv_coreXXX.dll, opencv_flannXXX.dll, opencv_imgprocXXX.dll and opencv_features2dXXX.dll and some system DLLs.
Using the project structure generated by CMake, a free tool for cross-platform compilation which is used for compliing OpenCV from sources. For instance, if I generate the project structure for VS2010 and open it, I can right-click on the project associated to opencv_calib3d and view the project dependencies.
I mentionned the tools I know and use for Windows, but equivalent tools must also exist for other platforms.
http://qt-project.org/doc/qt-4.8/deployment-windows.html say:
Before we can build our application we must make sure that Qt is built statically. To do this, go to a command prompt and type the following:
cd C:\path\to\Qt
configure -static <any other options you need>
doing so result in:
'configure' is not recognized as an internal or external command,
operable program or batch file.
is there any step by step guide explaining how can I configure my QT project so that it produces statically linked binaries?
Also, this guide seem to expect user to have full msvc compiler, I am using MinGW so I have no setenv batches
Make sure you've downloaded the .zip variant of Qt sources (4.8.5). The .tar.gz one is missing configure.exe, at least for Qt 5.
It should work then.
Note that there are two levels of "staticness":
Qt itself as a static library.
Qt's (and your application's) dependency on the C/C++ runtime.
Since you likely want both, you must coerce Qt itself to statically link with the C/C++ runtime library. I've not done it for mingw yet, but it will require changing the relevant qmake.conf. This change will propagate to the code you build using such tweaked Qt, so your application will statically link to both Qt and to the C/C++ runtime.
Using MSVC2012 and link time code generation, after UPX-ing the executable, the size is ~3mb for a small application using the gui and network modules. Just to give an idea of how big it will be. It'll likely be larger when using mingw.
I want to create a program that could work on any computer without the source code, How is that possible? and does it make any difference if I used OpenGL in the Program?
You cannot code a program in C++ that would work on any computer without giving your source code to be compiled.
For example, you could perhaps code in C++ a program, and compile it and build an executable which works on Windows x86-64, but that executable won't work on Linux (or MacOSX), and it won't work on ARM (e.g. Android phones) unless you consider using emulators
If you are developing your code with Visual C++ you may need to consider two options:
Make sure you link all libraries statically.
Install on the target computers along with your program Microsoft Visual C++ Redistributable Package corresponding to the Visual C++ version you use like the one at http://www.microsoft.com/download/en/details.aspx?id=5555. Some installer generating software will make it for you automatically.
Normally you would link your object file with some sort of a platform dependent loader. This loader loads your object and does all the stuff to start it from memory. Normally you can tell your compiler to link your object file and compile a blob. OpenGL is a powerful API and is usually distributed as a.dynamic linked library and is linked at runtime to your program. If I remember you just have to make sure the dll is where you want it and load the dll in your program from start.
Your C++ program is compiled and linked into an executable before it is run. You should be able to find that executable in a Debug or Release subfolder of the folder containing your project.
OpenGL, if you're not using GLUT or similar libraries, should just come with Windows and pose no additional problems. If you do use GLUT, it's enough to bundle the .dll file with your application.
In any case, the source code won't be necessary.
I want to create a program that could work on any computer without the source code, How is that possible? and does it make any difference if I used OpenGL in the Program?
By compiling and linking it into an executable. As long as you're not using some interpreted language (like Python, Ruby or such) you're presented with an executable inevitably. The biggest problem you may/will run into is dependencies on libraries. However those are linked into a binary as well. So what you're going to ship will be just a .exe; and some .dll maybe. Usually you'd wrap this in a installer package for deployment to the end user. Installers are created with something like the "NullSoft Installer System" (NSIS).
OpenGL itself is just a API, provided by a system library. So you don't ship OpenGL with your program, but expect the user to have it installed on the system (which will be the case if he installed the graphics drivers).