-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate symbols with libbwa #693
Comments
I'm having trouble getting this to happen, at least with my small test program. How did you build htslib and bwa, and what are you trying to build that joins them together? |
Also, are you building from Xcode and do you have -ObjC set in your linker flags? |
Hi @daviesrob, Thanks for the quick reply. I build htslib with a regular @valeriuo : I am building from the command line using CMake and Make (in this case with the default OSX compiler --- i.e. Apple Clang). I don't have -ObjC set. All of the code I'm building is either C or C++ (specifically C++11). Thanks, |
Hi all, I realized the awesome SeqLib library links both libbwa and libhts. So, I dug into things a little bit, and realized they actually had to hack the kstring.c/kstring.h in bwa as so. The fact that you have to actually modify the source of one or the other library is not the most satisfying solution, but it does, of course, work in my case. Best, |
Seeing as HTSlib is a widely-used library packaged and distributed in both shared and static form (and is probably the canonical source of third-party use of shared klib functionality), while libbwa.a is a non-installed intermediate file produced while building the bwa executable which a handful of other projects reach into and link against, it seems to me that the appropriate place to work around this is in libbwa. Ideally bwa's build system could be patched so you could (optionally) compile bwa's source files against HTSlib's edition of the klib headers and omit the k*.o files supplied by HTSlib from libbwa.a. This is complicated by the fact that HTSlib provides only a subset of the klib facilities used by bwa. The easy way to work around this would be to patch bwa's klib header like this: diff --git bwa/kstring.h bwa/kstring.h
index fe7fa95..13d374f 100644
--- bwa/kstring.h.orig
+++ bwa/kstring.h
@@ -20,6 +20,11 @@ typedef struct __kstring_t {
} kstring_t;
#endif
+// Avoid conflicting with HTSlib's kstring.c functions, to enable
+// linking against both libbwa and libhts. We #define each function
+// in BWA's kstring.c, which is currently just one function.
+#define ksprintf bwa_ksprintf
+
static inline void ks_resize(kstring_t *s, size_t size)
{
if (s->m < size) {
Salmon could achieve this without patching bwa source code at all by building its copy of libbwa.a with |
Prevent clashes with other libraries that use the Attactive Chaos version of kstring.h by putting an hts_ prefix in front of all the external symbols. The API is preserved by adding static inline wrappers around the renamed symbols. Relatively trivial functions ksprintf(), kstrstr() and kstrnstr() are moved into the header file. Fixes samtools#693 (Duplicate symbols with libbwa)
Make ksprintf() static inline in kstring.h, so that it (like the other bwa/kstring.h functions) won't conflict with similar HTSlib functions. Instead implement it and kvsprintf() in terms of a new bwa_kvsprintf() function. Fixes samtools/htslib#693.
Make ksprintf() static inline in kstring.h, so that it (like the other bwa/kstring.h functions) won't conflict with similar HTSlib functions. Instead implement it and kvsprintf() in terms of a new bwa_kvsprintf() function. Fixes samtools/htslib#693.
Hi,
First, thank you all for htslib. This is an amazing resource and incredibly useful library. I have a project that includes uses both libbwa and libhts. However both of these (linked statically) seem to include the same symbol
_ksprintf
. The specific error is:any suggestions about how to avoid this?
Thanks!
Rob
The text was updated successfully, but these errors were encountered: