"Nichtaufgeloestes externes Symbol" - Was nun?
-
Hallo!
Ich schreibe gerade ein kleines Konsolen-Programm und habe nun folgendes Problem:
Wenn ich das Programm kompilieren will, bekomme ich folgende Fehlermeldung:
--------------------Konfiguration: tdos - Win32 Debug--------------------
Kompilierung läuft...
tdos.cpp
Linker-Vorgang läuft...
tdos.obj : error LNK2001: Nichtaufgeloestes externes Symbol _readdir
tdos.obj : error LNK2001: Nichtaufgeloestes externes Symbol _opendir
Debug/tdos.exe : fatal error LNK1120: 2 unaufgeloeste externe Verweise
Fehler beim Ausführen von link.exe.Der Code:
[cpp] #include "stdafx.h" #include <string.h> #include <dirent.h> #include <stdio.h> #include <conio.h> #include <dos.h> char cmd [32]; char parameter[128]; struct dirent *path; DIR *dir; void file_move(){ char filea[128], fileb[128]; int success; dir = opendir("."); path = readdir(dir); printf(path->d_name); printf("FILE TO MOVE> "); scanf("%s", filea); printf("NEW PATH> "); scanf("%s", fileb); success = rename(filea, fileb); if(success == 0){ printf("The file %s was successful renamed to %s\n", filea, fileb); } else { printf("The file %s was not found or the file %s already exist\nCould not move file %s to %s", filea, fileb, filea, fileb); } } int main(int argc, char* argv[]) { while(1){ printf("\nCOMMAND> "); scanf("%s", cmd); if( (0 == stricmp("quit", cmd)) || (0 == stricmp("exit", cmd))){ return 0; } else if( 0 == stricmp("move", cmd)){ file_move(); } } } [/cpp]
Ich habs auch schon mit
[cpp] extern int __opendir_flags; extern int __readdir_flags; [/cpp]
versucht...
Was mach ich falsch?
Bitte helft mir!
-
das sieht ganz so aus, aus hättest du die Funktionen readdir und opendir nicht implementiert, musst dies aber tun, damit der Compiler bzw. der Linker den Code zu den Funktionen finden kann.
Gruß Sebastian
-
Ich hab in der Hilfe nachgelesen und da stand, dass ich nur
[cpp] extern int __opendir_flags; extern int __readdir_flags; [/cpp]
hinzufügen muss...
und damit klappts auch nicht!
-
Ich glaub ich bin zu blöd dafür
Könnte mir einer bitte den Code posten, den ich noch einfügen muss?Schonmal danke
-
Hallo,
dirent.h gibt es standardmäßig nicht für den VC++-Compiler (opendir und readdir sind auch nicht Bestandteil der C-Runtime von Windows!), woher hast du also diese Datei? Du solltest entweder _findfirst/_findnext bzw. ihre WinAPI-Entsprechungen, oder auch dieses Thema
http://www.c-plusplus.net/forum/viewtopic.php?t=80885
lesen.
MfG
-
sehe gerade, daß du die Frage schon einmal gestellt hast
:
http://www.c-plusplus.net/forum/viewtopic.php?t=80963
dann weißt du ja jetzt, warum ich nachgefragt habe, und worauf ich hinaus wollte.
MfG