06-13-2025 03:21 AM
i compiled the c code file in visual studio code. i even used __declspec(dllexport) in my code. but i'm also facing an issue in labview that is unresolved external symbols error.
my os is windows
the process followed:
Compile the source file into object code:
gcc -Wall -Werror -fpic -I./Include -I/msys64/ucrt64/include/libxml2 -c xml_handling.c -o xml_handling.o
Create a DLL from the object file:
gcc -shared -o xml_handling2.dll xml_handling.o -lxml2 -lz -LC:\msys64\ucrt64\lib
Compile the test program and link it against the DLL:
gcc -Wall xml_handling.c -o xml_handling.exe -I./Include -I/msys64/ucrt64/include/libxml2 -L.-lxml_handling -L/msys64/ucrt64/lib -lxml2
here the .exe file is working during compile time. but when i use the .dll in labview i'm facing the external symbol error. how can i solve these issue.
is there any way to generate and use the .dll without any dependencies in labview? if not then how can i generate .dll and how to use that in labview with dependencies
Solved! Go to Solution.
06-13-2025 03:13 AM
sorry for interfering in the middle of these. i'm also facing the same issue in labview unresolved external symbols error. but my os is windows: i compiled the c code file in visual studio code
i even used __declspec(dllexport) in my code.
Compile the source file into object code:
gcc -Wall -Werror -fpic -I./Include -I/msys64/ucrt64/include/libxml2 -c xml_handling.c -o xml_handling.o
Create a DLL from the object file:
gcc -shared -o xml_handling2.dll xml_handling.o -lxml2 -lz -LC:\msys64\ucrt64\lib
Compile the test program and link it against the DLL:
gcc -Wall xml_handling.c -o xml_handling.exe -I./Include -I/msys64/ucrt64/include/libxml2 -L.-lxml_handling -L/msys64/ucrt64/lib -lxml2
here the .exe file is working during compile time. but when i use the .dll in labview i'm facing the external symbol error. how can i solve these issue.
is there any way to generate and use the .dll without any dependencies in labview? if not then how can i generate .dll and how to use that in labview with dependencies
06-13-2025 04:52 AM - edited 06-13-2025 05:24 AM
The only dependencies I see are the following:
So, these four files shall be suffcient:
17.12.2024 20:10 1.135.869 libiconv-2.dll
11.04.2025 14:19 189.434 liblzma-5.dll
18.02.2025 21:51 1.309.996 libxml2-2.dll
23.01.2024 09:51 100.279 zlib1.dll
C Source for minimal DLL:
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string.h>
#include <stdio.h>
// Function to parse XML and print root element name
__declspec(dllexport) int parseXML(const char *filename, char* lv_root, char* lv_content) {
xmlDoc *document = xmlReadFile(filename, NULL, 0);
if (document == NULL) return -1;
xmlNode *root = xmlDocGetRootElement(document);
strcpy(lv_root, root->name);
// Get content of the root element
xmlChar *content = xmlNodeGetContent(root);
if (content) {
strcpy(lv_content, content);
xmlFree(content);
}
xmlFreeDoc(document);
xmlCleanupParser();
return 0;
}
Test XML File
<?xml version="1.0" encoding="UTF-8"?>
<MyRoot>
<MyChild>MyContent</MyChild>
</MyRoot>
Snippet and works:
Test project (including dependent DLLs) is in the attachment.
Update: Sorry, I didn't realize you're using Linux. I don't have access to a Linux system at the moment, but it should work similarly in general. I can prepare a version for Linux as well, just not right now.
06-13-2025 11:07 PM
In general, I'm not sure how Linux is applicable here (maybe the initial question was AI-generated), but anyway, I've checked this and, in general, it's almost the same.
C source:
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string.h>
#include <stdio.h>
#if defined(_WIN32) || defined(__CYGWIN__)
# define EXPORT __declspec(dllexport)
#else
# define EXPORT __attribute__ ((visibility ("default")))
#endif
// Function to parse XML and print root element name
EXPORT int parseXML(const char *filename, char* lv_root, char* lv_content) {
xmlDoc *document = xmlReadFile(filename, NULL, 0);
if (document == NULL) return -1;
xmlNode *root = xmlDocGetRootElement(document);
strcpy(lv_root, root->name);
// Get content of the root element
xmlChar *content = xmlNodeGetContent(root);
if (content) {
strcpy(lv_content, content);
xmlFree(content);
}
xmlFreeDoc(document);
xmlCleanupParser();
return 0;
}
Compiled as
gcc -shared -o xml_parser.so xml_parser.c -I/usr/include/libxml2 -lxml2 -fPIC
Dependencies:
ldd ./xml_parser.so
linux-vdso.so.1
libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2
libc.so.6 => /usr/lib/x86_64-linux-gnu/libc.so.6
libicuuc.so.70 => /usr/lib/x86_64-linux-gnu/libicuuc.so.70
libz.so.1 => /usr/lib/x86_64-linux-gnu/libz.so.1
liblzma.so.5 => /usr/lib/x86_64-linux-gnu/liblzma.so.5
libm.so.6 => /usr/lib/x86_64-linux-gnu/libm.so.6
/lib64/ld-linux-x86-64.so.2
libicudata.so.70 => /usr/lib/x86_64-linux-gnu/libicudata.so.70
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
libgcc_s.so.1 => /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
and works exactly same:
06-16-2025 03:20 AM
Thank You
06-16-2025 03:23 AM
@Maneeha wrote:
Thank You
Andrey_DmitrievI solved it.
You're welcome, glad to see it was helpful for you! And sorry about my wrong suggestion that it was AI-generated question.