Errorcode C3861 nach verwendung einer Biliotheksfunktion
-
Hallo,
ich habe gerade versucht ein Programmbeispiel von Matrox (Matrox Imaging Library) nachzuprogrammieren. Bei folgendem Quellcode bekomme ich die angesprochene Fehlermeldung:/* Regular includes. */ #include <stdio.h> #include <mil.h> #include <stdlib.h> /* Lens characteristics */ #define FOCUS_MAX_NB_POSITIONS 256 #define FOCUS_MIN_POSITION 0 #define FOCUS_MAX_POSITION 255 #define FOCUS_START_POSITION 0 /* Autofocus search properties */ #define FOCUS_MAX_POSITION_VARIATION 32 #define FOCUS_MODE M_SMART_SCAN #define FOCUS_SENSITIVITY 1 /* Autofocus hook function that is responsible to move the lens */ long MFTYPE MoveLensFunction(long HookType, long position, void MPTYPE *UserDataPtr); /* Main application function */ /****************************************************************/ void main(void) { MIL_ID MilApplication, /* Application identifier. */ MilSystem, /* System identifier. */ MilDisplay, /* Display identifier. */ MilDigitizer, /* Digitizer identifier. */ MilImage; /* Image buffer identifier. */ long FocusPos; /* Best focus position */ /* Allocate defaults */ MappAllocDefault(M_SETUP, &MilApplication, &MilSystem, &MilDisplay, &MilDigitizer, &MilImage); /* Grab continuously. */ MdigGrabContinuous(MilDigitizer, MilImage); /* Pause to show the original image. */ printf("An autofocus operation will be performed.\n"); printf("Press <Enter> to continue.\n"); getchar(); printf("Autofocusing...\n"); /* Perform autofocus by calling the MoveLensFunction iteratively */ MdigFocus (MilDigitizer, MilImage, M_DEFAULT, MoveLensFunction, M_NULL, FOCUS_MIN_POSITION, FOCUS_START_POSITION, FOCUS_MAX_POSITION, FOCUS_MAX_POSITION_VARIATION, FOCUS_MODE + FOCUS_SENSITIVITY, &FocusPos); /* Print the best focus position and number of iterations*/ printf("The best focus position is %d.\n", FocusPos); printf("Press <Enter> to end.\n"); getchar(); /* Free all allocations */ MappFreeDefault(MilApplication, MilSystem, MilDisplay, MilDigitizer, MilImage); } /* Autofocus hook function that is responsible to move the lens */ /****************************************************************/ long MFTYPE MoveLensFunction(long HookType, long position, void MPTYPE *UserDataPtr) { /* If focus position must be changed */ if(HookType == M_CHANGE) { /* Move the camera lens to the specified position using the appropriate interface (e.g. serial port). */ MoveLens(position);//<< hier } return 0; }Er meckert folgendermaßen:
c:...focus image.cpp(76) : error C3861: 'MoveLens': identifier not found
Dabei mach ich einfach nix anderes als das Programmbeispiel.*Mod-Edit* die cpp-Tags sind leider nicht kompatibel mit BBCode-Formatierungen
-
Die Fehlermeldung ist doch eindeutig - der Compiler kennt die Funktion MoveLens() nicht. Ich würde ja spontan auf einen Tippfehler spekulieren, aber da ich die Matrox-Bibliothek nicht kenne, kann ich da nur raten - schau doch mal in die Doku, wie die Funktion korrekt heißt (und welche(n) Header du dafür benötigst).
-
Sicher ist der Fehler eindeutig. Deshalb umso erstaunlicher. Die schreibweise hab ich schon kontrolliert, aber das stimmt. Ich brauche dafür den mil.h Header.
-
Könntest du mal den Code dort oben vernünftig einrücken, damit man etwas erkennt? (btw, gehört die Zeile 48/49 auch zu deinem Programm? wenn ja, geht das wirklich durch den Compiler?)
PS: Und "void main()" war noch nie gültiger C++ Code.
-
Hier nochmal formatiert:
abrissbirne schrieb:
/* Regular includes. */ #include <stdio.h> #include <mil.h> #include <stdlib.h> /* Lens characteristics */ #define FOCUS_MAX_NB_POSITIONS 256 #define FOCUS_MIN_POSITION 0 #define FOCUS_MAX_POSITION 255 #define FOCUS_START_POSITION 0 /* Autofocus search properties */ #define FOCUS_MAX_POSITION_VARIATION 32 #define FOCUS_MODE M_SMART_SCAN #define FOCUS_SENSITIVITY 1 /* Autofocus hook function that is responsible to move the lens */ long MFTYPE MoveLensFunction(long HookType, long position, void MPTYPE *UserDataPtr); /* Main application function */ /****************************************************************/ void main(void) { MIL_ID MilApplication, /* Application identifier. */ MilSystem, /* System identifier. */ MilDisplay, /* Display identifier. */ MilDigitizer, /* Digitizer identifier. */ MilImage; /* Image buffer identifier. */ long FocusPos; /* Best focus position */ /* Allocate defaults */ MappAllocDefault(M_SETUP, &MilApplication, &MilSystem, &MilDisplay, &MilDigitizer, &MilImage); /* Grab continuously. */ MdigGrabContinuous(MilDigitizer, MilImage); /* Pause to show the original image. */ printf("An autofocus operation will be performed.\n"); printf("Press <Enter> to continue.\n"); getchar(); printf("Autofocusing...\n"); /* Perform autofocus by calling the MoveLensFunction iteratively */ MdigFocus (MilDigitizer, MilImage, M_DEFAULT, MoveLensFunction, M_NULL, FOCUS_MIN_POSITION, FOCUS_START_POSITION, FOCUS_MAX_POSITION, FOCUS_MAX_POSITION_VARIATION, FOCUS_MODE + FOCUS_SENSITIVITY, &FocusPos); /* Print the best focus position and number of iterations*/ printf("The best focus position is %d.\n", FocusPos); 32 Camera auto-focus (continued) printf("Press <Enter> to end.\n"); getchar(); /* Free all allocations */ MappFreeDefault(MilApplication, MilSystem, MilDisplay, MilDigitizer, MilImage); } /* Autofocus hook function that is responsible to move the lens */ /****************************************************************/ long MFTYPE MoveLensFunction(long HookType, long position, void MPTYPE *UserDataPtr) { /* If focus position must be changed */ if(HookType == M_CHANGE) { /* Move the camera lens to the specified position using the appropriate interface (e.g. serial port). */ MoveLens(position);//<< hier } return 0; }
-
Habs komplett neu formatiert. hoffe man kann es so besser lesen.
-
abrissbirne schrieb:
Habs komplett neu formatiert. hoffe man kann es so besser lesen.
Danke, schonmal.
Wichtig wäre beim Formatieren, Einrückungen in "Klammerebenen".
Also z.B. so:/* Regular includes. */ #include <stdio.h> #include <mil.h> #include <stdlib.h> /* Lens characteristics */ #define FOCUS_MAX_NB_POSITIONS 256 #define FOCUS_MIN_POSITION 0 #define FOCUS_MAX_POSITION 255 #define FOCUS_START_POSITION 0 /* Autofocus search properties */ #define FOCUS_MAX_POSITION_VARIATION 32 #define FOCUS_MODE M_SMART_SCAN #define FOCUS_SENSITIVITY 1 /* Autofocus hook function that is responsible to move the lens */ long MFTYPE MoveLensFunction(long HookType, long position, void MPTYPE *UserDataPtr); /* Main application function */ /****************************************************************/ void main(void) { MIL_ID MilApplication, /* Application identifier. */ MilSystem, /* System identifier. */ MilDisplay, /* Display identifier. */ MilDigitizer, /* Digitizer identifier. */ MilImage; /* Image buffer identifier. */ long FocusPos; /* Best focus position */ /* Allocate defaults */ MappAllocDefault(M_SETUP, &MilApplication, &MilSystem, &MilDisplay, &MilDigitizer, &MilImage); /* Grab continuously. */ MdigGrabContinuous(MilDigitizer, MilImage); /* Pause to show the original image. */ printf("An autofocus operation will be performed.\n"); printf("Press <Enter> to continue.\n"); getchar(); printf("Autofocusing...\n"); /* Perform autofocus by calling the MoveLensFunction iteratively */ MdigFocus (MilDigitizer, MilImage, M_DEFAULT, MoveLensFunction, M_NULL, FOCUS_MIN_POSITION, FOCUS_START_POSITION, FOCUS_MAX_POSITION, FOCUS_MAX_POSITION_VARIATION, FOCUS_MODE + FOCUS_SENSITIVITY, &FocusPos); /* Print the best focus position and number of iterations*/ printf("The best focus position is %d.\n", FocusPos); printf("Press <Enter> to end.\n"); getchar(); /* Free all allocations */ MappFreeDefault(MilApplication, MilSystem, MilDisplay, MilDigitizer, MilImage); } /* Autofocus hook function that is responsible to move the lens */ /****************************************************************/ long MFTYPE MoveLensFunction(long HookType, long position, void MPTYPE *UserDataPtr) { /* If focus position must be changed */ if(HookType == M_CHANGE) { /* Move the camera lens to the specified position using the appropriate interface (e.g. serial port). */ MoveLens(position);//<< hier } return 0; }Spontan würde ich sagen:
1.) Ist reines C und sollte deswegen entweder in C++ gewandelt werden oder ins entsprechendem Forum verschoben werden2.) "void man(void)" gibt's IIRC auch in C nicht.
3.) Die Frage bleibt: Wo ist MoveLens() implementiert ?
Sprich: Welcher Code soll in der mit "<<hier" gekennzeichneten Stelle ausgeführt werden ?
Vermutlich ist das in der Matrox-Lib implementiert ... dann musst Du die dem LInker auch "mitgeben" (wie das geht, findest Du in der Beschreibung Deines Compilers/Linkers...Gruß,
Simon2.
-
C3861 ist ein Compiler-Fehler. Linkercodes fangen mit LNK und nicht C an. Wird wohl einfach in einem Header die Funktion fehlen. Kann man doch einfach durch eine Suchfunktion im Windows-Explorer feststellen...
-
Ja, hab alles in mein Projekt mit aufgenommen. Hab die Bibliothek mil.lib in den Ordner C:\Programme\Microsoft Visual Studio 8\VC\lib hineinkopiert. Danach unter Projekt Properties --> C/C++ --> General --> Additional Include Directories den Pfad zu dem Matrox Includeverzeichnis angegeben und unter Linker --> Input --> Additional Dependencies mil.lib eingegeben. Somit müsste ich es doch korrekt eingebunden haben.
-
Schau mal im Header <mil.h> nach, ob die Funktion 'MoveLens' wirklich so heißt und ob es irgendwelche defines dort gibt, welche evtl. noch aktiviert werden müssen.
-
Danke für eure schnellen Hilfsvorschläge. Hab den Täter allen Übels. Wir verwenden hier nur eine abgespeckte Version der MIL, die MIL-LITE und diese besitzt nur Core-Funktionen.