A problem about libnodave

B

Thread Starter

bart

Hi!
I need your help. I want to use libnodave to comminucate with S7300. When I use the example file testS7online.exe to connect to PLC, it works well. But when I want to compile the source file testS7online.c,wrong message was showed "libnodave-0[1].8.4.4\nodave.h(106) : fatal error C1189: #error : Fill in what you need for your OS or API.".

I have tryed the VC and Borland C++ compiler to compiler,but both were failed. I don't why. Even I defined the BCCWIN,more wrong messages were appeared.

If you can help me solve this porblem or have a compileable source, please tell me. Thank you.
Regards!
 
OS is Windows XP SP2,complier is Visual Studio 6.0 and Broland c++ complier 5.5. Can the libnodave work in Windows?
 
M

Michael Griffin

In the "README.compiling" file, it says:

##############

How to compile in different enviroments:

5. Borland Free Commandline Tools
Adjust the path to make in winmake.bat.
Adjust paths in MAKEFILE.MAK to your installation.
Run batch file winmake.bat.

##############

A little further down, it says:

##############

Q: I try to compile my source code which includes nodave.h. Why do I get:
"#error Fill in what you need for your OS or API" ?

A: Libnodave has to use different functions to read byte data from serial ports or TCP/IP streams depending on the operating system. You have to specify which OS you compile for.

Define BCCWIN for Windows and LINUX for Linux or other Unix style operating systems. I do that using -DBCCWIN or -DLINUX when I call the compilers out of a Makefile. If you use an IDE (integrated development environment), refer to
the IDE's documentation to learn where to do this. If you can't find out, you can help yourself putting the #define into your code (which means your code will not be portable to other OS without modification). example:

...
#define BCCWIN // if you work on windows
#include nodave.h // or nodavesimple.h, but NEVER both
#include setport.h // if your code works with serial connections
#include openSocket.h // if your code works with TCP/IP

##############

In your other message you said you were using Microsoft Visual Studio. I would guess that your problem is related to something in Visual Studio. I would suggest that you try compiling without using Microsoft Visual Studio (as the
author of libnodave recommends).
 
Hello Bart;
Libnodave was originally written for Linux, but they support Windows compilers:

The goal of this project
This project aims to provide a free library in C source. It is written with and for LINUX. There is support for compiling it with Borland C-Compiler from Borland's free command line tools for Win32. It has been compiled and found to work also on FreeBSD. Anybody more familiar with other operating systems is hereby encouraged to port it.

http://libnodave.sourceforge.net/index.php

Hope this helps,
Daniel Chartier
 
Hi, dchartier, Michael Griffin.

Thanks for your answers.

Yesterday, I compiled the program in Visual Studio 6.0, it succeeded. I defined BCCWIN in nodave.h, and replaced "extern int seconds, thirds;" in benchmark.c with "int seconds, thirds;". Setting the libnodave.lib in the link array. Then the source file testS7online.c can be compiled.

My goal is to encapsulate some of the libnodave's functions in a COM with ATL. I think compiling the test example is the first step for me. I am a freshman in this field. I don't even know what "FLAG","DB" means in the source file.

Thanks for your support.
 
where do you put this BCCWIN define statement?

I tried putting it in different places but it still returns the same error.

Thanks
 
> where do you put this BCCWIN define
> statement?

You can put these #defines on the command line of your compiler or within the Makefile.

Example for Gnu C Compiler:
%mingwdir%\bin\gcc.exe nodave.c -o nodave_mingw.o
-c -D_WIN32 -DBCCWIN -I%mingwdir%\include
 
I was wondering if you could help me. I need to compile these test programs too. I am a beginner to C++.

When I try to compile, it gives me the following error:

"fatal error C1189: #error : Fill in what you need for your OS or API."

when I click on the error, it shows these lines in the header file:

#ifndef OS_KNOWN
#error Fill in what you need for your OS or API.
#endif

Can you tell me where I need to put the #define BCCWIN statement? Thank you for your time
 
> I'm trying to compile using the Visual C++ 6.0

Beneath the GUI it is the same stuff.
Instead of gcc.exe you have a cl.exe

In your GUI select project->settings->C/C++
You have to use this command line option of cl.<pre>
/D<Name>{=|#}<Text> Makro definieren

/DBCCWIN
instead of
-DBCCWIN

The C/C++ compiler in VCPP supports this commandline args:

cl /help

OPTIONEN FUER C/C++-COMPILER

-OPTIMIERUNG-

/O1 Speicherbedarf minimieren /Op[-] Fliesskommakonsistenz
verbessern
/O2 Geschwindigkeit maximieren /Os Kompakten Code generieren
/Oa Kein Aliasing /Ot Schnellen Code generieren
/Ob<n> Inline-Expansion (Standard n=0) /Ow Funktionsuebergreifendes Aliasing
/Od Keine Optimierungen (Standard) /Ox Maximale Optimierungen
(/Ogityb1 /Gs)
/Og Globale Optimierungen /Oy[-] Keine Rahmenzeiger
/Oi Integrierte Funktionen einfuegen

-CODE-GENERIERUNG-

/G3 Optimieren fuer 80386 /Gy Separate Funktionen fuer Linker
/G4 Optimieren fuer 80486 /Ge Stack-Pruefung fuer alle Funktionen erzwingen
/G5 Optimieren fuer Pentium /Gs[num] Stack-Pruefung deaktivieren
/G6 Optimieren fuer Pentium Pro /Gh Hook-Funktion aufrufen
/GB bestmoegliche Optimierung (Standard) /GR[-] C++ RTTI
/Gd Aufrufkonvention __cdecl /GX[-] C++ Ausnahmebehandlung (= /EHsc)
/Gr Aufrufkonvention __fastcall /Gi[-] Inkrementelle Kompilierung
/Gz Aufrufkonvention __stdcall /Gm[-] Minimale Neukompilierung
/GA Optimieren fuer Windows-Anwendung /EHs Synchrone C++ Ausnahmebehandlung
/GD Optimieren fuer Windows-DLL /EHa Asynchrone C++ Ausnahmebehandlung
/Gf Gleiche Zeichenfolgen zusammenfassen /EHc extern "C" ergibt nothrow
/GF Schreibgeschuetzt ablegen /QIfdiv[-] Pentium FDIV-Fehlerbehebung
/GZ Debug-Pruefungen zur Laufzeit /QI0f[-] Pentium 0x0f-Fehlerbehebung

-AUSGABEDATEIEN-

/Fa[Datei] Assembler-Listing-Datei /Fo<Datei> Objektdatei
/FA[sc] Assembler-Listing konfigurieren /Fp<Datei> Vorkompilierte Header-Datei
/Fd[Datei] .PDB-Datei /Fr[Datei] .SBR-Datei
/Fe<Datei> Ausfuehrbare Datei /FR[Datei] Erweiterte .SBR-Datei
/Fm[Datei] Map-Datei

-PRAEPROZESSOR-

/C Keine Kommentare entfernen /FI<Datei> Explizite Include-Datei
/D<Name>{=|#}<Text> Makro definieren /U<Name> Vordefiniertes Makro entfernen/E Praeprozessor-Ausgabe nach stdout /u All vordefinierten Makros entfernen
/EP Praeprozessor-Ausgabe nach stdout /I<Verz> Hinzufuegen zum Include-
ohne Zeilennummer. Suchpfad.
/P Praeprozessor-Ausgabe in Datei /X "Standardstellen" ignorieren

-PROGRAMMIERSPRACHE-

/Zi Debugger-Info generieren /Zl Kein Standard-Bibliotheksname in .OBJ
/ZI Debug-Info fuer Bearbeiten und Fortfahren aktivieren /Zg Funktionsprototypen generieren
/Z7 Debugger-Info generieren (alt) /Zs Nur Syntaxueberpruefung
/Zd Nur Zeilennummern als Debugger-Info /vd{0|1} vtordisp aktivieren/deaktivieren
/Zp[n] Strukturen an n-Byte-Grenzen /vm<x> Typ von Elementzeigern
/Za Keine Erweiterungen (impliziert /Op) /noBool Schluesselwort "bool" deaktivieren
/Ze Erweiterungen aktivieren (Standard)

-VERSCHIEDENES-

/?, /help Diese Seiten anzeigen /V<Zeichenfolge> Versionszeichenfolge
/c Nur kompilieren, kein Binden /w Alle Warnungen deaktivieren
/H<Laenge> Max. Laenge externer Namen /W<n> Warnstufe setzen (Standard n=1)
/J Standardmaessig unsigned char /WX Alle Warnungen sind Fehler
/nologo Keine Copyright-Meldung /Yc[Datei] .PCH-Datei erstellen
/Tc<Quelldatei> Datei als .c kompilieren /Yd Debugger-Info in allen .OBJ-Dateien
/Tp<Quelldatei> Datei als .cpp kompilieren /Yu[Datei] .PCH-Datei verwenden
/TC Alle Dateien als .c kompilieren /YX[Datei] .PCH-Datei automatisch
/TP Alle Dateien als .cpp kompilieren /Zm<n> Max. Speicher (% von Standard)

-LINKER-

/MD Binden mit MSVCRT.LIB /MDd Binden mit MSVCRTD.LIB fuer Debugger
/ML Binden mit LIBC.LIB /MLd Binden mit LIBCD.LIB fuer Debugger
/MT Binden mit LIBCMT.LIB /MTd Binden mit LIBCMTD.LIB fuer Debugger
/LD .DLL erstellen /F<Groesse> Stack-Groesse setzen
/LDd Debugger-Bibliothek erstellen /link [Linker-Optionen und Bibliotheken]</pre>
 
When I try to put in #define in my file, it comes back with more errors. 43 to be exact. Here are some of the errors:

estISO_TCP.obj : error LNK2001: unresolved external symbol __imp___daveDump@12
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__daveStrerror@4
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__daveReadSZL@20
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__endUpload@8
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__doUpload@20
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__initUpload@16
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__daveBlockName@4
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__daveListBlocksOfType@12
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__daveExecReadRequest@12
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__daveAddVarToReadRequest@20
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__davePrepareReadRequest@8
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__daveReadBytes@24
testISO_TCP.obj : error LNK2001: unresolved external symbol _thirds
testISO_TCP.obj : error LNK2001: unresolved external symbol _seconds
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__daveWriteBytes@24
testISO_TCP.obj : error LNK2001: unresolved external symbol __imp__closeSocket@4

Thanks for the help.
 
I was able to compile the program with zero errors thanks to the solution by Bart. Thanks to all who helped. My next step is to establish a connection with a S-300 PLC. Can anyone help me with how to do that? Thank you.


 
Top