Part of my school project I need to work with LabWindows/CVI.
I need to read a xlsx file and analize it.
I download this libxl library.
I amported the h files and the lib files.
this is my code ( I coppied it from here):
#include <cvirte.h>
#include <userint.h>
#include <formatio.h>
#include "Final work.h"
#include "libxl.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int panelHandle;
int readFile()
{
BookHandle book = xlCreateBook(); // xlCreateXMLBook()
if (xlBookLoad(book, "G:/Electro data/0.5_time_all.xlsx")){
return 0;
}
if(book)
{
SheetHandle sheet = xlBookAddSheet(book, L"Sheet1", 0);
if(sheet)
{
xlSheetWriteStr(sheet, 2, 1, L"Hello, World !", NULL);
xlSheetWriteNum(sheet, 3, 1, 1000, NULL);
}
xlBookSave(book, L"example.xls");
xlBookRelease(book);
}
return 0;
}
and I am getting this errors:
Build Status (Final work.prj - Debug)
Final work.c - 3 warnings
error: Undefined symbol '_xlBookAddSheetA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlBookLoadA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlBookReleaseA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlBookSaveA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlCreateBookCA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlSheetWriteNumA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlSheetWriteStrA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
Build failed.
here is an image to illustrate:
What am I doing wrong?
You need to link with the provided library. From the screenshot you seem to have added the library to your project, however the linker does not get it.
Related
I want to use C code which depends on babeltrace2 in Rust.
For now I have in my main.rs, where prepare_graph is a custom C function:
#[link(name = "bt_util", kind = "static")]
extern "C" {
fn prepare_graph(
ctf_directory: *const c_char,
plugins_directory: *const c_char
) -> c_int;
}
with libbabeltrace/bt_util.c:
#include <babeltrace2/babeltrace.h>
#include "bt_util.h"
int prepare_graph(const char *ctf_directory, const char *plugins_directory) {
bt_graph *graph = bt_graph_create(0);
int error_code = 0;
bt_plugin_find_all_from_dir_status ret;
const bt_plugin_set *plugins;
...
}
it is built with the following build.rs:
extern crate cmake;
use cmake::Config;
fn main(){
let babeltrace_path = Config::new("libbabeltrace").build();
println!("cargo:rustc-link-search=native={}", babeltrace_path.display());
println!("cargo:rustc-link-lib=static=bt_util");
}
and the libbabeltrace/CMakeLists.txt:
cmake_minimum_required(VERSION 3.22)
project(LibBabeltrace C)
set(CMAKE_C_STANDARD 17)
include(ExternalProject)
include(FetchContent)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)
include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
ExternalProject_Add(babeltrace2
GIT_REPOSITORY https://github.com/efficios/babeltrace.git
GIT_TAG v2.0.4
BUILD_IN_SOURCE 0
WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/babeltrace2
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/babeltrace2
CONFIGURE_COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/babeltrace2/bootstrap && BABELTRACE_DEBUG_MODE=1 BABELTRACE_DEV_MODE=1 BABELTRACE_MINIMAL_LOG_LEVEL=TRACE BABELTRACE_PLUGINS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/babeltrace2/plugins ./configure --disable-man-pages --disable-glibtest --disable-doxygen-doc --disable-doxygen-html --prefix "${EXTERNAL_INSTALL_LOCATION}"
BUILD_COMMAND ${MAKE_EXE}
BUILD_ALWAYS FALSE
)
add_custom_target(build_external
DEPENDS babeltrace2
)
add_library(bt_util STATIC src/bt_util.c)
install(TARGETS bt_util DESTINATION .)
As can be seen the libbabeltrace/bt_util.c depends on an external library (babeltrace2).
This leads to a compilation error within the build.rs which is due to not being able to link the external library.
Compiling ctf_reader v0.1.0 (/home/tk/Documents/bitaggregat/minimal-stide-examples/Rust)
error: linking with `cc` failed: exit status: 1
|
...
= note: /usr/bin/ld: .../target/debug/build/ctf_reader-13cbb68ba72803ed/out/libbt_util.a(bt_util.c.o): in function `my_consumer_func':
.../libbabeltrace/src/bt_util.c:18: undefined reference to `bt_message_get_type'
/usr/bin/ld: .../libbabeltrace/src/bt_util.c:24: undefined reference to `bt_message_event_borrow_event_const'
/usr/bin/ld: .../libbabeltrace/src/bt_util.c:25: undefined reference to `bt_event_borrow_class_const'
/usr/bin/ld: .../libbabeltrace/src/bt_util.c:29: undefined reference to `bt_event_borrow_payload_field_const'
...
error: could not compile `ctf_reader` due to previous error
Couldn't find resources on including C with dependencies.
I know there is also a babeltrace2-sys crate. But I couldn't get this to work with system call traces.
Any help appreciated.
foo.exe depends on bar.lib
source.c in bar.lib:
#include <time.h>
void func()
{
time_t now = time(NULL);
... // use 'now'
}
Bar.lib can be generated. However, foo.exe's linking process will report an error:
LINK2019
unresolved external symbol '_time64' referenced in function 'time'.
foo
bar.lib(source.obj)
What may cause this?
I'm trying to configure VS correctly to write some simple c programs.
If a function dummy() is not found, the function name is not highlight in the code, there is only a build error:
LNK2019 unresolved external symbol dummy referenced in function main
Line: 1
Is there a way to make VS intellisense work for function names with .c files?
Why compiler doesn't show the error line number (Line: 1 is not very helpful)?
Sample:
#include <stdio.h>
#include <stdlib.h>
void dummy()
{
}
int main()
{
dummyX(); //dummyX, dummy typo. Results in "unresolved external..." error
return EXIT_SUCCESS;
}
I have started using gsl recenltly in a huge old C project. I have managed to add the libraries by adding the location in my system in Properties>C/C++>General>Additional Include Directories.
In my code, I am also including the following:
#include "gsl/gsl_matrix.h"
#include "gsl/gsl_matrix_complex_double.h"
#include "gsl/gsl_matrix_complex_float.h"
#include "gsl/gsl_matrix_complex_long_double.h"
#include "gsl/gsl_math.h"
#include "gsl/gsl_spmatrix.h"
#include "gsl/gsl_complex.h"
#include "gsl/gsl_complex_math.h"
#include "gsl/gsl_inline.h"
#include "gsl/gsl_complex.h"
I can now use most functions of gsl. but in the fowllowing function:
void vector_complex_mul_elements(gsl_vector_complex *v1, gsl_vector_complex *v2)
{
gsl_complex cpx1, cpx2, cpx3;
GSL_SET_COMPLEX(&cpx1, 0, 0);
GSL_SET_COMPLEX(&cpx2, 0, 0);
GSL_SET_COMPLEX(&cpx3, 0, 0);
if(v1->size != v2->size)
{
printf("Error: Lenght of arrays do not match.\n");
return;
}
for(i=0; i < v1->size; i++)
{
cpx1 = gsl_vector_complex_get(v1, i);
cpx2 = gsl_vector_complex_get(v2, i);
//cpx3 = gsl_complex_mul(cpx1 , cpx2);
gsl_vector_complex_set(v1, i, cpx3);
}
}
When I uncomment the line:
cpx3 = gsl_complex_mul(cpx1 , cpx2);
I get the following errors:
Error LNK2001: Unresolved external symbol "_log1p".
Error LNK2001: Unresolved external symbol "_log1p".
Error LNK2001: Unresolved external symbol "_hypot".
Error LNK1120: 2 unresolved external references.
I have already tried writing it like:
gsl_vector_complex_set(v1, i, gsl_complex_mul(cpx1 , cpx2));
Then I get these errors:
Error LNK2019: Reference to unresolved external symbol "_log1p" in function "_gsl_complex_logabs".
Error LNK2019: Reference to unresolved external symbol "_hypot" in function "_gsl_complex_div".
Error LNK2001: Unresolved external symbol "_log1p".
Error LNK1120: 2 unresolved external references.
Is this a only a linking problem or the way I am using it is wrong?
These (lop1p and hypot) functions are in the standard maths library. Are you including math.h and linking to it (-lm)? As per the GSL documentation.
It seems to me that you are wrong linked GSL library.
Try to rebuild GSL as a dll and relink it, as I showed you in your other post.
I am trying to compile a C file containing this code :
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
int main()
{
curl_global_init( CURL_GLOBAL_ALL );
CURL * myHandle;
CURLcode result; // We’ll store the result of CURL’s webpage retrieval, for simple error checking.
myHandle = curl_easy_init ( ) ;
// Notice the lack of major error checking, for brevity
curl_easy_setopt(myHandle, CURLOPT_URL, "http://www.example.com");
result = curl_easy_perform( myHandle );
curl_easy_cleanup( myHandle );
printf("LibCurl rules!\n");
return 0;
}
,
Well when I try to compile :
gcc url.c -lcurl
I get the following errors:
F:\MinGW\home>gcc url.c -lcurl
C:\Users\Ehsan\AppData\Local\Temp\ccF7doFN.o:url.c:(.text+0x8e): undefined reference to `_imp__curl_global_init'
C:\Users\Ehsan\AppData\Local\Temp\ccF7doFN.o:url.c:(.text+0x95): undefined reference to `_imp__curl_easy_init'
C:\Users\Ehsan\AppData\Local\Temp\ccF7doFN.o:url.c:(.text+0xbf): undefined reference to `_imp__curl_easy_setopt'
C:\Users\Ehsan\AppData\Local\Temp\ccF7doFN.o:url.c:(.text+0xcd): undefined reference to `_imp__curl_easy_perform'
C:\Users\Ehsan\AppData\Local\Temp\ccF7doFN.o:url.c:(.text+0xdf): undefined reference to `_imp__curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
I downloaded this distribution
and copied all files to bin, include , and lib folder.
What am I missing?
Update
Well I fixed the problem by using -lcurldll.
In my lib folder I have both libcurl.a and libcurldll.a.
Why linking with libcurl.a can't compile but with libcurldll.a it works fine?
You can check the lib name by:
readelf -d [LIB_PATH]
That would solve you the problem.