Skip to content
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

pkg-config gives invalid gcc and clang XMLSEC_CRYPTO definition #10

Closed
lsh123 opened this issue Jan 28, 2016 · 1 comment
Closed

pkg-config gives invalid gcc and clang XMLSEC_CRYPTO definition #10

lsh123 opened this issue Jan 28, 2016 · 1 comment

Comments

@lsh123
Copy link
Owner

lsh123 commented Jan 28, 2016

* Tom Burdick [reporter] 2014-07-29 20:17:50 UTC*

When attempting to compile my own xmlsec based library and the examples and directly using the pkg-config flags the XMLSEC_CRYPTO definition causes errors due to the quote escaping. This is with xmlsec 1.2.20 on archlinux (no patches)

This is particularly frustrating at the moment as I'm writing a Go binding to libxml/libxslt/xmlsec and Go does not let me do anything to modify the results of pkg-config output when doing its thing.

GCC 4.9.1 Output:


gcc $(pkg-config --cflags --libs xmlsec1) sign1.c -o sign1                                                                                                                        :(
<command-line>:0:16: warning: missing terminating " character
sign1.c: In function ‘main’:
sign1.c:93:5: error: stray ‘\’ in program
     if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
     ^
sign1.c:93:5: error: missing terminating " character
sign1.c:93:56: error: expected expression before ‘)’ token
     if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
                                                        ^

clang 3.4.2 Output:


clang $(pkg-config --cflags --libs xmlsec1) sign1.c -o sign1                                                                                                                      :(
In file included from <built-in>:161:
<command line>:1:24: warning: missing terminating '"' character [-Winvalid-pp-token]
#define XMLSEC_CRYPTO \"openssl\"
                       ^
sign1.c:93:43: error: expected expression
    if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
                                          ^
<command line>:1:23: note: expanded from here
#define XMLSEC_CRYPTO \"openssl\"
                      ^
sign1.c:184:43: warning: passing 'const char *' to parameter of type 'const xmlChar *' (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
    if(xmlSecKeySetName(dsigCtx->signKey, key_file) < 0) {
                                          ^~~~~~~~
/usr/include/xmlsec1/xmlsec/keys.h:197:73: note: passing argument to parameter 'name' here
                                                         const xmlChar* name);
                                                                        ^
2 warnings and 1 error generated.
1 tburdick@rocket ~/src/xmlsec/examples (git)-[master] % clang --version                                                                                                                                                                   :(
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Go output for my bindings:


go build
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
# github.com/bfrog/xml
<command-line>:0:16: warning: missing terminating " character
./xml.c: In function ‘init’:
./xml.c:43:5: error: stray ‘\’ in program
     if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
     ^
./xml.c:43:5: error: missing terminating " character
./xml.c:43:56: error: expected expression before ‘)’ token
     if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
                                                    ^

Any ideas on how to solve this in the meantime would be really appreciated, for my own purposes I just ended up sticking the string literal for now temporarily into xmlSecCryptoDLLoadLibrary("openssl") like so but that seems fragile

[reply] [−] Comment 1 Aleksey Sanin [xmlsec developer] 2014-08-04 16:04:34 UTC

The GCC error doesn't look like pkg-config problem and some clang errors look weird as well...

Unfortunately, I am not exactly sure what is the problem here. I've just tried on latest Ubuntu I have and it worked w/o problem. Do you have any problems running 'make' in the xmlsec1/examples folder?

[reply] [−] Comment 2 Tom Burdick [reporter] 2014-08-05 03:59:42 UTC

The makefile in the xmlsec/examples folder does something very different than what most users of pkg-config would be doing I'd think? Its assigning the results of a shell command to a variable first.

I unfortunately cannot do that with go as Cgo enforces some very specific meta comments in Go that let me do very little.

In either case even the pkg-config docs say to use pkg-config as I have here in their examples. I would think it should work.

It seems like maybe there's too many escapes or not enough escapes going on here?

http://golang.org/cmd/cgo/

http://people.freedesktop.org/~dbn/pkg-config-guide.html

Migrated from: https://bugzilla.gnome.org/show_bug.cgi?id=733935

@lsh123
Copy link
Owner Author

lsh123 commented Feb 6, 2016

Fixed by getting rid of XMLSEC_CRYPTO define. There is no good way to handle string defines in pkg-config. This might create backward compatibility problems though I made an effort to make it an unlikely event. Plus I think it is a better way forward anyway

#20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant