Jump to content
  • 0

How to compile the c samples for Analog Discovery 2 on Win?


derov

Question

Hi!)

I installed Waveforms2015 on my system (Windows).  The "pythone" scripts is working well.

 

When I compile C examples (IDE Code::Blocks 16, GNU GCC compiler),  receive a  errors:

.....................

C:\CODE\digilent\OpenDev\main.c|12|undefined reference to `FDwfDeviceOpen'|
C:\CODE\digilent\OpenDev\main.c|13|undefined reference to `FDwfGetLastErrorMsg'|
.....................

 

How to compile the c samples for Analog Discovery on Win?

Whether it is necessary for this Microsoft Visual C++?

 

 

Kind regards,

Alex

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

Hi JColvin!

Thanks for the answer. 

1. On the one hand:  IDE Code::Bloks works correctly. For check, in the example project (analogin_sample.c + dwf.h + sample.h + dwf.lib ). I have changed original files (analogin_sample.c + sample.h + dwf.lib) for own stub  files with the same names (simple program + external function in lib). The stub project was compiled well. That is IDE is settings correctly, but the problem remained.

2. On the other hand: in the "Reply to Custom designed Signal with Analog Discovery" post, the same problem has been solved!

3. The list of obj files in library (dwf.lib) (dumpbin.exe /exports dwf.lib  >> out) contains the  necessary references

...............

                  FDwfDeviceConfigOpen
                  FDwfDeviceEnableSet
                  FDwfDeviceOpen
                  FDwfDeviceReset
                  FDwfDeviceTriggerGet

.................

But direct procedure of compilation doesn't work

gcc -std=c99 -c analogin_sample.c                           -->                 analogin_sample.o

gcc analogin_sample.o dwf.lib -o out.exe                  -> ............

analogin_sample.o:analogin_sample.c:(.text+0x51): undefined reference to `FDwfDeviceOpen'
analogin_sample.o:analogin_sample.c:(.text+0x67): undefined reference to `FDwfGetLastErrorMsg'
analogin_sample.o:analogin_sample.c:(.text+0xa7): undefined reference to `FDwfAnalogInChannelOffsetSet'
analogin_sample.o:analogin_sample.c:(.text+0xc1): undefined reference to `FDwfAnalogInChannelRangeSet'
analogin_sample.o:analogin_sample.c:(.text+0xd5): undefined reference to `FDwfAnalogInConfigure'
analogin_sample.o:analogin_sample.c:(.text+0x122): undefined reference to `FDwfAnalogInStatus'
analogin_sample.o:analogin_sample.c:(.text+0x137): undefined reference to `FDwfAnalogInStatusSample'
analogin_sample.o:analogin_sample.c:(.text+0x160): undefined reference to `FDwfDeviceCloseAll'
collect2: ld returned 1 exit status

 

Some questions:

1. GNU GCC (mingw) whether is compatible with dwf.lib?

2. What compiler you use?

 

Alex

Link to comment
Share on other sites

Hi Alex,

Unfortunately, I personally can't answer all of the questions, but I do have a clarification question for you. Did you link to just dwf or did you link to dwf.lib? The other thread that attila answered recommended that you just use dwf, but some of the things you posted above still make reference to dwf.lib.

Thanks,
JColvin

Link to comment
Share on other sites

Hi attila!

1. It seems to me in sample.h there are problems, for example:

sample.h
..................................................

#ifdef WIN32
           #include "../../inc/dwf.h"
#else
           #include <digilent/waveforms/dwf.h>
#endif

.............................................

Windows instalation  WaveForms v3.2.6 doesn't contain <digilent/waveforms/dwf.h>, but contains  <Digilent/WaveFormsSDK/inc/dwf.h>

 

2. I have compiled  WaveFormsSDK  examples by Microsoft Visual Studio 2013 on Winx64, by:

2.0.        Create "Win 32 Console Application Project".

2.1.       While config "Win 32 Application Wizard" -->   Application Settings -> Unmark "Precompiled header".

2.2.       Delete all  default "header & source" files from project.

2.3.      Copy  "sample.h, dwf.h, analogin_sample.c, dwf.lib (from Digilent/WaveFormsSDK/lib/x64)" to project catalog (may be to ../include, ../lib subcatalogs).

2.4.      Add  "sample.h, dwf.h, analogin_sample.c" to project.

2.5      Edit "sample.h"

.............................................................

#include <stdio.h>
#include <stdlib.h>

#ifdef WIN32
/* #include "../../inc/dwf.h" */
#include "dwf.h"
#else
/* #include <digilent/waveforms/dwf.h> */
#include "dwf.h"
#endif

#ifdef WIN32
    #include <windows.h>
    #define Wait(ts) Sleep((int)(1000*ts))
#else
    #include <unistd.h>
    #include <sys/time.h>
    #define Wait(ts) usleep((int)(1000000*ts))
#endif

...............................

2.6  Project Properties   -->  In "Configuration Manager"  (top, right button)  it is necessary to create a configuration "x64"

            Configuration Manager  --> Active solution platform --> New Solution Platform --> Type or selected the new platform --> x64

                                                        Active solution platform --> must be x64

 

2.7.  Project Properties   -->   C\C++   -->  General  -->  Additional Include Directories  --> "To add the catalog with:  sample.h, dwf.h   files"

 

2.8.  Project Properties   -->   C\C++   -->  All Options  -->  Calling Convention  --> "__cdecl (/Gd)"

 

2.9.  Project Properties   -->   C\C++   -->  All Options  -->  Compile as  --> "Compile as C code (/TC)"

 

2.10.  Project Properties   -->   Linker   -->  General  -->  Additional Library Directories  --> "To add the catalog with  dwf.lib  file"

 

2.11.  Project Properties   -->   Linker   -->  Input  -->  Additional Dependencies  --> "To add the 'dwf.lib;' string  in file list"


 

 

dig_vs.7z

Link to comment
Share on other sites

Hello,

On Windows there is no generic include folder, so the path to dwf.h is given relative to the provided examples.
The <digilent/waveforms/dwf.h> is for Linux, which directs to system's generic include folder.
In the latest version (3.3.7) it is specified for OS X too, /Library/Frameworks/dwf.framework/Headers/dwf.h.

For next version I will add build instructions for different systems and build platforms.

Thank you for your observations,
Attila

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...