GaGsOn Posted April 18, 2014 Share Posted April 18, 2014 გამარჯობათ, პროგრამას ვწერ Server/Client სოკეტის გამოყენებით და #include <winsok2.h> ამ ბიბლიოთეკას რო ვიყენებ ერორს მიწერს ვერ ხედავს 5 C:UsersuserDesktopTCP_winsock_cppServermain.ccp.cpp winsok2.h: No such file or directory. და როგორ შეძლება რო დაინახოს თუ შეგიძლიათ რო დამეხმაროთ. Dev C++ ვიყენებ კომპილერს. Link to comment Share on other sites More sharing options...
მიშო Posted April 18, 2014 Share Posted April 18, 2014 რეფერენსებში დამატება ხომ არ უნდა ბიბლიოთეკას? ვიზუალ სტუდიოში(c#) მქონია ასეთი შემთხვევა Link to comment Share on other sites More sharing options...
ოთო Posted April 18, 2014 Share Posted April 18, 2014 C-ის ბიბლიოთეკით რომ დაწერო? ცოტახნის წინ დამჭირდა რაღაც მსგავსი ჩემი პროექტისთვის. კოდის პატარა ნაწილია და შეგიძლია გამოიყენო. რამე თუ ვერ გაიგე მკითხე #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #ifndef NI_MAXHOST #define NI_MAXHOST 1025 #endif #ifndef NI_MAXSERV #define NI_MAXSERV 32 #endif static int tcp_connect(char *host, char *port) { struct addrinfo hints, *ai_list, *ai; int n, fd = 0; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; n = getaddrinfo(host, port, &hints, &ai_list); if (n != 0) { fprintf(stderr, "%s: getaddrinfo: %sn", progname, gai_strerror(n)); exit(EXIT_FAILURE); } for (ai = ai_list; ai; ai = ai->ai_next) { fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (fd < 0) { switch (errno) { case EAFNOSUPPORT: case EPROTONOSUPPORT: continue; default: fprintf(stderr, "%s: socket: %sn", progname, strerror(errno)); continue; } } else { if (connect(fd, ai->ai_addr, ai->ai_addrlen) == -1) { close(fd); fprintf(stderr, "%s: connect: %sn", progname, strerror(errno)); continue; } } break; /* still here? we were successful and we are done */ } freeaddrinfo(ai_list); if (ai == NULL) { fprintf(stderr, "%s: could not connect to %s port %sn", progname, host, port); exit(EXIT_FAILURE); } return fd; } static int tcp_close(int fd) { return close(fd); } Link to comment Share on other sites More sharing options...
GaGsOn Posted April 18, 2014 Author Share Posted April 18, 2014 ოთო, ამ კოდის დაკომპილირება ვცადე და #include <sys/socket.h> და #include <netdb.h> ეს ორი ბიბლიოტეკა ვერ დაინახე, როგორ დავანახო ხოარ იცი ან ობჯექთში რამე ბიბლიოთეკა ხოარ უნდა მიუთითო? Link to comment Share on other sites More sharing options...
მიშო Posted April 18, 2014 Share Posted April 18, 2014 ოთო, ამ კოდის დაკომპილირება ვცადე და #include <sys/socket.h> და #include <netdb.h> ეს ორი ბიბლიოტეკა ვერ დაინახე, როგორ დავანახო ხოარ იცი ან ობჯექთში რამე ბიბლიოთეკა ხოარ უნდა მიუთითო? No such file or directory The error I’m looking at today most commonly occurs when you are including a header file using the preprocessor #include directive. For example, suppose you have the following code in a file called myfile.cpp: #include "myheader.h" and you get the following error message: myfile.cpp:1:22: fatal error: myheader.h: No such file or directory compilation terminated. What could be causing it? Well, the basic cause is that the compiler cannot find a file called myheader.h in the directories it searches when processing the #include directive. This could be so for a number of reasons. The simplest reason is that you want the compiler to look for myheader.h in the same directory as the myfile.cpp source file, but it can’t find it. this may be because you simply haven’t created the header file yet, but the more common reason is that you either misspelled the header file name in the #include directive, or that you made a mistake in naming the header file when you created it with your editor. Look very closely at the names in both the C++ source and in your source code directory listing. You may be tempted to think "I know that file is there!", but if the compiler says it isn’t there, then it isn’t, no matter how sure you are that it is. This problem is somewhat greater on Unix-like system, such as Linux, as there file names are character case sensitive, so Myheader.h, MyHeader.h, myheader.h and so on would all name different files, and if you get the case wrong, the compiler will not look for something "similar". For this reason, a very good rule of thumb is: Never use mixed case when naming C++ source and header files. Use only alphanumeric characters and the underscore when naming C+++ files. Never include spaces or other special characters in file names. Apart from avoiding file not found errors, this will also make life much easier if you are porting your code to other operating systems which may or may not respect character case. The wrong directory? Another situation where you may get this error message is if you have split your header files up from your C++ source files into separate directories. This is generally good practice, but can cause problems. Suppose your C++ project is rooted at C:/myprojects/aproject, and that in the aproject directory you have two sub-directorys called src (for the .cpp files) and inc (for the header files), and you put myfile.cpp in the src directory, and myheader.h in the inc directory, so that you have this setup: myprojects aproject inc myheader.h src myfile.cpp Now if you compile the source myfile.cpp from the src directory, you will get the "No such file or directory" error message. The C++ compiler knows nothing about the directory structures of your project, and won’t look in the inc directory for the header. You need to tell it to look there somehow. One thing some people try when faced with this problem is to re-write myfile.cpp so it looks like this: #include "c:/myprojects/aproject/inc/myheader.h" or the slightly more sophisticated: #include "../inc/myheader.h" Both of these are a bad idea, as they tie your C++ code to the project’s directory structure and/or location, both of which you will probably want to change at some point in the future. If the directory structure does change, you will have to edit all your #include directories.The better way to deal with this problem is to tell the compiler directly where to look for header files. You can do that with the compiler’s -I option, which tells the compiler to look in the specified directory, as well as the ones it normally searches: g++ -Ic:/myprojects/aproject/inc myfile.cpp Now the original #include directive: #include "myheader.h" will work, and if your directory structure changes you need only modify the compiler command line. Of course, writing such command lines is error prone, and you should put such stuff in a makefile, the use of which is unfortunately outside the scope of this article. Link to comment Share on other sites More sharing options...
GaGsOn Posted April 18, 2014 Author Share Posted April 18, 2014 მივხვდი რა პრობლემაცაა თუ ზუსტად გავიგე, ეს UNIX ბიბლიოთეკა რომელიც ვინდოუში არ მუშაობს, ვინდოუსში სხვა ბიბლიოთეკა გამოიყენება და ამიტომაც ვერ ხედავს Link to comment Share on other sites More sharing options...
ოთო Posted April 18, 2014 Share Posted April 18, 2014 ოთო, ამ კოდის დაკომპილირება ვცადე და #include <sys/socket.h> და #include <netdb.h> ეს ორი ბიბლიოტეკა ვერ დაინახე, როგორ დავანახო ხოარ იცი ან ობჯექთში რამე ბიბლიოთეკა ხოარ უნდა მიუთითო? ვინდოუსზე თუ აკეთებ ალბათ ვერ დინახავს. ლინუქსზეა ეგ ბიბლიოთეკები ნუ საერთოდ ვინდუსი არაა საუკეთესო პლატფორმა ცოტა კომპლექსური პროგრამებისთვის. ძლიან ბევრი ბიბლიოთეკა არააქვს და კუსტაურლი გზებით მოგიწევს რაღაცეებს კეთება. virtualbox გადმოწერე და virtual machine -ზე გაუშვი ubuntu Link to comment Share on other sites More sharing options...
GaGsOn Posted April 18, 2014 Author Share Posted April 18, 2014 ვინდოუსზე მჭირდება და მაგიტო ვჩალიჩობ ეგრე. ეხლა რაგაც სხვა ბიბლიოთეკები ვნახე რაც ვინდოუსზე მუშაობს და თუარ იმუშავა მერე მომიწევს ეგრე გაკეთება. მადლობა დახმარებისთვის. Link to comment Share on other sites More sharing options...
მიშო Posted April 19, 2014 Share Posted April 19, 2014 თემა დაიხურა, თუ რამეა მომწერე და გავხსნი Link to comment Share on other sites More sharing options...
Recommended Posts