How to build a dylib from several .o in Mac OS X using gcc
Use g++ -dynamiclib -undefined suppress -flat_namespace *.o -o something.dylib
Use g++ -dynamiclib -undefined suppress -flat_namespace *.o -o something.dylib
You can unset the prefix with this line: set_target_properties(foo PROPERTIES PREFIX “”)
Nothing is needed at compile time, because C has a notion of separate compilation of translation units. But once all the different sources have been compiled, it is time to link everything together. The notion of shared library is not present in the standard but is it now a common thing, so here is how … Read more
As already stated in other answers, this behavior is intended. There is some kind of workaround if you can compile (or at least link) the application yourself. Then you can pass -Wl,-rpath <yourDynamicLibraryPath> to gcc or -rpath <yourDynamicLibraryPath> to ld and you won’t have to specify LD_LIBRARY_PATH at all on execution.
You want something more like this (and here I will use a slightly more meaningful example): C/C++ header – animal.h #ifndef ANIMAL_H #define ANIMAL_H #ifdef __cplusplus class Animal { public: Animal() : age(0), height(0) {} Animal(int age, float height) : age(age), height(height) {} virtual ~Animal() {} int getAge(); void setAge(int new_age); float getHeight(); void setHeight(float … Read more
For most of the suppression types, you omit the wildcard, like so: { name Memcheck:Cond obj:/path/to/lib/lib.so.10.1 } { name Memcheck:Free obj:/path/to/lib/lib.so.10.1 } { name Memcheck:Value8 obj:/path/to/lib/lib.so.10.1 } Note that you must list each type of error separately, you can’t wildcard them. You must also list the entire pathname of the library (as shown by valgrind, … Read more
How about: data.c #include <stdio.h> struct A { int a_id; }; struct B { int b_id; struct A a_nested; }; void dump_b(struct B* b) { printf(“B.b_id: %d\n”, b->b_id); printf(“B.a_nested.a_id: %d\n”, b->a_nested.a_id); } fiddle.rb # frozen_string_literal: true require ‘fiddle’ require ‘fiddle/import’ module Test extend Fiddle::Importer dlload ‘./data.dylib’ B = struct [ “int id”, “int a_id” ] … Read more
Let’s say you have the following C source file, call it name.c #include <stdio.h> #include <stdlib.h> void print_name(const char * name) { printf(“My name is %s\n”, name); } When you compile it, with cc name.c you generate name.o. The .o contains the compiled code and data for all functions and variables defined in name.c, as … Read more
What are “unused DT entry” errors? If you have reached this page, it’s probably because you have compiled or attempted to run some binaries on your ARM based Android system, with the result that your binary/app crashes or generates a lot of warnings in your logcat. Typically something like this: WARNING: linker: /blahblah/libopenssl.so: unused DT … Read more