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

Compiling plget on MSYS2 results in missing header <libxml/tree.h> #1

Closed
mast3rz3ro opened this issue Mar 10, 2024 · 4 comments
Closed

Comments

@mast3rz3ro
Copy link
Contributor

Hi,

I have libxml2-devel Installed but problem still presents.

$ ./configure.sh
libxml2: built-in
Done. Now run: make

$ make
gcc plget.c -o plget -lxml2
plget.c:3:10: fatal error: libxml/tree.h: No such file or directory
    3 | #include <libxml/tree.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:8: plget] Error 1
@mast3rz3ro
Copy link
Contributor Author

According to this answer I was able to pass this error by replacing LDFLAGS=-lxml2 with LDFLAGS=-I/usr/include/libxml2

But now I'm getting this error:

$ make
gcc plget.c -o plget -I/usr/include/libxml2
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x7b): undefined reference to `__imp_xmlParseFile'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0xdc): undefined reference to `__imp_xmlDocGetRootElement'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x128): undefined reference to `__imp_xmlFreeDoc'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x188): undefined reference to `__imp_xmlFreeDoc'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x1c3): undefined reference to `__imp_xmlStrcmp'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x1f6): undefined reference to `__imp_xmlStrcmp'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x34b): undefined reference to `__imp_xmlStrcmp'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x3be): undefined reference to `__imp_xmlStrcmp'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x3f3): undefined reference to `__imp_xmlStrcmp'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x434): undefined reference to `__imp_xmlFreeDoc'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x463): undefined reference to `__imp_xmlFree'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x49f): undefined reference to `__imp_xmlFree'
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyVR9XL.o:plget.c:(.text+0x4d0): undefined reference to `__imp_xmlNodeListGetString'
collect2: error: ld returned 1 exit status
make: *** [Makefile:8: plget] Error 1

Trying to compile with g++ instead of gcc results in:

$ make
g++ plget.c -o plget -I/usr/include/libxml2
plget.c: In function ‘path_t* createComps(const char*)’:
plget.c:168:41: error: invalid conversion from ‘void*’ to ‘Path’ {aka ‘path_t*’} [-fpermissive]
  168 |                     path = tail = malloc(sizeof(struct path_t));
      |                                   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      |                                         |
      |                                         void*
plget.c:170:40: error: invalid conversion from ‘void*’ to ‘Path’ {aka ‘path_t*’} [-fpermissive]
  170 |                     tail->next = malloc(sizeof(struct path_t));
      |                                  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      |                                        |
      |                                        void*
make: *** [Makefile:8: plget] Error 1

@kallewoof
Copy link
Owner

I don't have MSYS2 available right now, but your compiler error indicates that you are not actually linking to the libxml2 libraries. -I just does the include part, you also have to link it.

@mast3rz3ro
Copy link
Contributor Author

I have finally manage to compile it, thanks for your hints.

configure.sh:19

echo -n -e "LDFLAGS=-lxml2\nCPPFLAGS=\n" > Makefile
into
echo -n -e "LDFLAGS=-lxml2 -I/usr/include/libxml2\nCPPFLAGS=\n" > Makefile

Thank you for this lightweight awesome tool !
Please feel free to close this issue ;).

@kallewoof
Copy link
Owner

Great! It would be nice if you made a pull request to update README.md with MSYS2 specific instructions, now that you have it figured out.

mast3rz3ro added a commit to mast3rz3ro/plget that referenced this issue Mar 13, 2024
kallewoof added a commit that referenced this issue Mar 14, 2024
Updated readme file + fixed error #1
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

2 participants