Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

unresolved symbol!

I am trying to utilize my DIO-96 to read the digital output of my decoder circuit in rt-linux.

What i have done is pretty simple - I tried to make the example codes (read digital port, provided by NI) as a function. Then i tried called that function in rt-linux, and execute in an infinite while loop. (the codes is ok in linux environment with a single reading of my digital input)

I get the error message of “unresolved symbol” for the functions I need (DAQmxBaseCreateTask… etc) when I compile my codes. The cause of this error is that I am trying to “load a module without a GPL compatible license and it has unresolved symbols”, the recommendation is to “contact the module supplier for assistance, only they can help you” – according to the hint of the error message.

I have link the .so (shared object) file in my makefile while compiling...

I wonder if anyone have similar experience?
0 Kudos
Message 1 of 6
(4,411 Views)
Hi,

Can you provide more information on your application? For example, what version of Linux and DAQmx Base are you using? Also, I'm assuming the error is from the compiler? If you can elaborate on what you're trying to accomplish on RT-Linux, and how the compilation differs from running it once in Linux, that would be helpful.

Thanks,
Lesley Y.
0 Kudos
Message 2 of 6
(4,394 Views)
I am using nidaqmxbase_1.4.0-f2. with rt-linux-3.2-pre1 and redhat 7.3.

Here i include my rtlinux code. As u can see, all i am doing is just to call a read function "DAQmxBaseReadDigitalU8" in my while loop.

//==================================================================================
#include
#include
#include
#include "NIDAQmxBase.h"

double rt;
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048];

// Channel parameters
const char chan[] = "Dev1/port0";

// Read parameters
uInt8 r_data [1];
int32 read;

pthread_t thread;

void * thread_code(void *arg)
{
struct sched_param p;
p . sched_priority = 1;
pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);
pthread_make_periodic_np (pthread_self(), gethrtime(), 100000000);

while (1) {
pthread_wait_np ();
DAQmxBaseReadDigitalU8(taskHandle,-1,0.0,DAQmx_Val_GroupByChannel,r_data,10,&read,NULL);
rtl_printf("Data read: 0x%X\n", r_data[0]);
}
}

int init_module(void) {
return pthread_create (&thread, NULL, thread_code, 0);
// Create Digital Output (DO) Task and Channel
DAQmxBaseCreateTask ("", &taskHandle);
DAQmxBaseCreateDIChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines);
// Start Task (configure port)
DAQmxBaseStartTask (taskHandle);
}

void cleanup_module(void) {
DAQmxBaseStopTask (taskHandle);
DAQmxBaseClearTask (taskHandle);
pthread_delete_np (thread);
}
//=====================================================================================

I tried the following:-
1. make -f rtl.mk hello2.o (compile my codes to get a object file named "hello2")
2. mv hello2.o hello2_tmp.o (rename the object file to another temporary name)
3. ld -r -call_shared -verbose hello2_tmp.o -o hello2.o -L/usr/local/natinst/nidaqmxbase/lib/nidaqmxbase - L/usr/local/natinst/nidaqmxbase/lib/nidaqmxbaselv -L/usr/local/natinst/nidaqmxbase/lib/lvrtdark
(here i tried to link the library file needed for all the pre-defined functions, such as DAQmxBaseReadDigitalU8 etc)
4. rtlinux start hello2.o (i tried to insert this module along with other rtlinux modules)
5. then i get the error messages:
hello2.o: unresolved symbol DAQmxBaseStopTask
hello2.o: unresolved symbol DAQmxBaseClearTask
hello2.o: unresolved symbol DAQmxBaseReadDigitalU8
hello2.o:
Hint: You are trying to load a module without a GPL compatible license and it has unresolved symbols.
Contact the module supplier for assistance, only thy can help you.

Strange thing is that the other three functions DAQmxBaseCreateTask, DAQmxBaseCreateDIChan and DAQmxBaseStartTask is ok. Something wrong with the library files? or the way i link the library file is no good?

Any ideas?
0 Kudos
Message 3 of 6
(4,392 Views)
Hi,

A few suggestions for your code:
1) Try moving the line, "return pthread_create(&thread, NULL, thread_code, 0); to the end of the init_module function. Since this line signifies the end of the function, the code following it will not be implemented.

2) In point 3 of what you've tried, change "-L/usr/local/natinst/nidaqmxbase/lib/nidaqmxbase" to "-lnidaqmxbase"

Furthermore, are you aware of any restrictions in the programs which RT-Linux can run? If you run the example code provided, is it successful?

Thanks,
Lesley Y.
0 Kudos
Message 4 of 6
(4,353 Views)
Thanks for the reply.

I have tried ur suggestion.

1. moving line "return pthread_create...." ==> now i get all the function calls return with an error of "unresolved symbols"

2. Change to "-Inidaqmxbase" ==> same error messages. It seems the loading(linking) of the library files is ok. I have checked:- the library files is in the correct directory - /usr/local/lib; also the library directory is in the config file of the linker - /usr/ld.so.conf.

I have ran the provided codes in Linux, it is ok. And there is no any restriction i am aware of.

Isn't rt-linux only provide an "extra capability" (scheduling) on top of linux?

Isn't it true that the library file (shared object file), which can be access by any linux version, always accessible in rt-linux?

mm.. i am a bit confused now... 😞
0 Kudos
Message 5 of 6
(4,345 Views)
Hi,

Although I am not a Linux expert, I have seen those "unresolved symbols" errors. I get them when I do not incude the header file or library. Basically, you are trying to call functions that the compiler has no idea where to find.

I would make sure that you are correctly including the header file. As a test, define a constant in the header file and try to read it back in the program. If you can't read back the constant you defined in the header, the header isn't being included.

Also, make sure that you have the compiler including the .dll that contains the functions.


Hope this helps.

-Sal
0 Kudos
Message 6 of 6
(4,334 Views)