• 0
Daniel Rech

Problems compiling Waveforms on C samples

Question

Hi everyone,

I downloaded digilent.waveforms_3.2.6_armhf.deb and installed it on my system.

The "dwfcmd" command is working fine and the python examples also work.

Now I want to compile the C examples and I keep getting errors:

analogin_trigger.c:(.text+0x74): undefined reference to `FDwfDeviceOpen'
analogin_trigger.c:(.text+0x9c): undefined reference to `FDwfGetLastErrorMsg'
analogin_trigger.c:(.text+0xd4): undefined reference to `FDwfAnalogInFrequencySet'
analogin_trigger.c:(.text+0xec): undefined reference to `FDwfAnalogInBufferSizeSet'
analogin_trigger.c:(.text+0x110): undefined reference to `FDwfAnalogInChannelEnableSet'
analogin_trigger.c:(.text+0x128): undefined reference to `FDwfAnalogInChannelRangeSet'
analogin_trigger.c:(.text+0x13c): undefined reference to `FDwfAnalogInTriggerAutoTimeoutSet'
analogin_trigger.c:(.text+0x154): undefined reference to `FDwfAnalogInTriggerSourceSet'
analogin_trigger.c:(.text+0x168): undefined reference to `FDwfAnalogInTriggerTypeSet'
analogin_trigger.c:(.text+0x17c): undefined reference to `FDwfAnalogInTriggerChannelSet'
analogin_trigger.c:(.text+0x190): undefined reference to `FDwfAnalogInTriggerLevelSet'
analogin_trigger.c:(.text+0x1a4): undefined reference to `FDwfAnalogInTriggerConditionSet'
analogin_trigger.c:(.text+0x1f4): undefined reference to `FDwfAnalogInConfigure'
analogin_trigger.c:(.text+0x208): undefined reference to `FDwfAnalogInStatus'
analogin_trigger.c:(.text+0x248): undefined reference to `FDwfAnalogInStatusData'
analogin_trigger.c:(.text+0x2dc): undefined reference to `FDwfDeviceCloseAll'

I used clang and gcc to build the analogin_trigger.c sample:

clang analogin_trigger.c

 

Where is my mistake?

Share this post


Link to post
Share on other sites

16 answers to this question

Recommended Posts

  • 0

Thank you, --> gcc analogin_trigger.c -ldwf worked.

Had to adjust the samples to get them running because the C syntax was dort of broken. Anyone interested in a github repository with fixed code?

Am I even allowed to share the samples, what's the license?

Share this post


Link to post
Share on other sites
  • 0

I had to run the following code to get the samples to work:

gcc-6 digitalout_pins.cpp -o digitalout_pins.out -I/Library/Frameworks/dwf.framework -framework dwf

./digitalout_pins.out

Yes, I'd be interested in a github repo! @attila What license is the sample code licensed under? Can you add a LICENSE file?

BTW, in sample.h the following line needs to be changed when running on OSX:

#include <digilent/waveforms/dwf.h>


because of the error during compilation:

sample.h:7:36: fatal error: digilent/waveforms/dwf.h: No such file or directory

The fix was to change it to:

#include "../../inc/dwf.h"

Any comments on this @attila?

Share this post


Link to post
Share on other sites
  • 0

I will add OS X specific include for the C examples. Currently it is defined only for Windows and Linux:
#ifdef WIN32
#include "../../inc/dwf.h"
#else
#include <digilent/waveforms/dwf.h>
#endif

I would recommend to take a look at the Python examples too. Here you will find few additional ones.

Share this post


Link to post
Share on other sites
  • 0

Hi Everyone,

I recently started using an Analog Discovery 2 and the WaveForm software. I've been trying to run the sample programs on Visual Studio but the #include "sample.h" produces many errors. Additionally, are there any online tutorials you recommend for a first time user?

Thank you in advance!

Nick

Share this post


Link to post
Share on other sites
  • 0
6 hours ago, Nick said:

the #include "sample.h" produces many errors

As a general rule of thumb, you can resolve the errors by resolving the associated problems.

For a more descriptive answer, please post a more descriptive question. :D

Chris

Edited by clf

Share this post


Link to post
Share on other sites
  • 0

Once I build the code, I obtain 1092 Errors, these include:

Function returning function is not allowed
Identifiers undefined "UCHAR", "PUCHAR", "LPPROCESS_INFORMATION", "ULONG", "PULONG", "DWORD", etc.
Expected a declaration
Error syntax error: '<'         c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 1
Error unknown character '0x60'        c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 2
Error unknown character '0x3'         c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error unknown character '0x1'         c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0x201a': this character is not allowed as a first character of an identifier  c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error unknown character '0xe'         c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0x81': this character is not allowed as a first character of an identifier  c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0xa1': this character is not allowed as a first character of an identifier  c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0x201e': this character is not allowed in an identifier    c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error unknown character '0x18'        c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0xa0': this character is not allowed as a first character of an identifier  c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0xa4': this character is not allowed in an identifier     c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0x9d': this character is not allowed as a first character of an identifier  c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error unknown character '0x10'        c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0x2039': this character is not allowed as a first character of an identifier  c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0x203a': this character is not allowed as a first character of an identifier  c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error '0x2020': this character is not allowed in an identifier    c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3
Error C3861 'Wait': identifier not found
Error unexpected end-of-file found        c:\waveform\digilent\waveformssdk\lib\x64\dwf.lib 3

Once I comment out the "sample.h" the only errors that show up are some identifiers not found or undefined.

Best Regards,
Nick

Share this post


Link to post
Share on other sites
  • 0

Hi @Nick

In Visual Studio make sure to create Visual C++ Win32 project.

Add the following linker input for your 32 or 64bit application:
C:\Program Files (x86)\Digilent\WaveFormsSDK\lib\(x86 or x64)\dwf.lib

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

@attila

Hello.

This thread is old and maybe closed, but it seems like the right place to post my question/ issue.

I am trying to compile the dwf sample cpp code from command-line on Mac Mojave (10.14.6) with Waveforms SDK 3.10.9 for Analog Discovery 2.  I get the following verbose command-line output.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

mks-MBP:analogout_custom mik$ g++ -v analogout_custom.cpp -o analogout_custom -L/Library/Frameworks/dwf.framework/Frameworks

Apple LLVM version 10.0.1 (clang-1001.0.46.4)

Target: x86_64-apple-darwin18.7.0

Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin

"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name analogout_custom.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 450.3 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -I/usr/local/include -stdlib=libc++ -Wno-atomic-implicit-seq-cst -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-quoted-include-in-framework-header -fdeprecated-macro -fdebug-compilation-dir /Users/mik/dev/analogout_custom -ferror-limit 19 -fmessage-length 154 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/jn/r_wvymcs2gqcygymghgcctzr0000gn/T/analogout_custom-1edf48.o -x c++ analogout_custom.cpp

clang -cc1 version 10.0.1 (clang-1001.0.46.4) default target x86_64-apple-darwin18.7.0

ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/v1"

ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/local/include"

ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/Library/Frameworks"

#include "..." search starts here:

#include <...> search starts here:

/usr/local/include

/Library/Developer/CommandLineTools/usr/include/c++/v1

/Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/include

/Library/Developer/CommandLineTools/usr/include

/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include

/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks (framework directory)

End of search list.

"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.14.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -o analogout_custom -L/Library/Frameworks/dwf.framework/Frameworks /var/folders/jn/r_wvymcs2gqcygymghgcctzr0000gn/T/analogout_custom-1edf48.o -L/usr/local/lib -lc++ -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/lib/darwin/libclang_rt.osx.a

Undefined symbols for architecture x86_64:

  "_FDwfAnalogOutConfigure", referenced from:

      _main in analogout_custom-1edf48.o

  "_FDwfAnalogOutNodeAmplitudeSet", referenced from:

      _main in analogout_custom-1edf48.o

  "_FDwfAnalogOutNodeDataSet", referenced from:

      _main in analogout_custom-1edf48.o

  "_FDwfAnalogOutNodeEnableSet", referenced from:

      _main in analogout_custom-1edf48.o

  "_FDwfAnalogOutNodeFrequencySet", referenced from:

      _main in analogout_custom-1edf48.o

  "_FDwfAnalogOutNodeFunctionSet", referenced from:

      _main in analogout_custom-1edf48.o

  "_FDwfDeviceCloseAll", referenced from:

      _main in analogout_custom-1edf48.o

  "_FDwfDeviceOpen", referenced from:

      _main in analogout_custom-1edf48.o

  "_FDwfGetLastErrorMsg", referenced from:

      _main in analogout_custom-1edf48.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 

Note thought that I was able to compile & link with Xcode though.  Just wondering if there's a way to get things to work with g++'s clang.

-mik

Edited by mik

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

Hi @attila

Thank you for the prompt reply.  Yes, I had seen that post and gave it a try too.  I got the following message.

mks-MBP:analogout_custom mik$ g++ analogout_custom.cpp -o analogout_custom -I/Library/Frameworks/dwf.framework -framework dwf

ld: framework not found dwf

clang: error: linker command failed with exit code 1 (use -v to see invocation)

-mik

Edited by mik

Share this post


Link to post
Share on other sites
  • 0

Hi @mik

Use F argument:

gcc device_enumeration.cpp -F /Library/Frameworks -framework dwf
g++ analogout_custom.cpp -o analogout_custom -F /Library/Frameworks -framework dwf

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now