I have a c Program and it was running Perfectly, but now i want to run it in Windows. So i am trying to compile the code in the Windows 7 Operating System, using Turboc3.
When i am compiling, i am getting an error "Unable to open include file Protocols.h"
But the Protocols.h file exists in the Directory. And all the directories are set perfectly in the C compiler.
From .c file it will include one .h file, and from that .h file another .h file is included.
But still i am facing the same issue, Can anyone help me out.
The header i have is like below:
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <signal.h>
//#include <wait.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
//#include <ipc.h>
//#include <shm.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define socklen_t int
/* limit values */
#define MAX_TAGS 500
#define MAX_OBJECTS 500
#include "Protocols.h"
If you really set the correct path in you compiler, you could try to hardcode the path like #include "/path/name.h".
If this works, you have some issue with your compiler and maybe not set the path (the right way).
If this does not work it seems, that the file is not existing or broken in some way. In this case: Get a new version of the headerfile and make sure, that it is in the right place.
Related
I have the following C code and I'm required to run it. but I always have the following Error in the used libraries. I tried downloading the MinGW and I added its path to the Environmental variables, but still same problem.
[Error] netdb.h: No such file or directory
I'm trying to run my code on Windows. It is a C language Socket program.
The libraries are:
#include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#define MAX 80
#define PORT 8080
#define SA struct sockaddr
Another question, If I want to run a socket on my laptop as a client and a server (windows), how do I do so?
I do the same stuff at these moment.
I had the problem too. If you run the script on windows, you have to install the right header files. I do it with...
#ifdef _WIN32
//For Windows
int betriebssystem = 1;
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <ws2def.h>
#pragma comment(lib, "Ws2_32.lib")
#include <windows.h>
#include <io.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
int betriebssystem = 2;
#endif
Try to run it. Maybe you have to link the libary for "ws2_32".
I am unable to compile my code successfully due to undefined references.
I am using the STM32Cube IDE compiler which is based of atollic true studio.
The undefined references are due to headers not linking.
I have included the headers into my main program and have included them in the include path for the compiler.
#include "base64_codec_transport.h"
#include "line_buffer_transport.h"
#include "modem_ussd_transport.h"
#include "thingstream_transport.h"
#include "client_api.h"
#include "client_platform.h"
#include "client_set_callback.h"
#include "custom_modem_transport.h"
#include "debug_printf_core.h"
#include "log_client_transport.h"
#include "log_modem_transport.h"
#include "log_protocol_transport.h"
#include "log_transport.h"
#include "modem2_transport.h"
#include "modem_set_callback.h"
#include "modem_transport.h"
#include "predefined_topics.h"
#include "quectel_modem2_config.h"
#include "ring_buffer_transport.h"
#include "sdk_data.h"
#include "serial_transport.h"
#include "sim7600_modem2_config.h"
#include "transport_api.h"
#include "ublox_modem2_config.h"
The consol errors are below:
All these functions are defined in their respective headers as follows, to give one example.
#define line_buffer_transport_create Thingstream_createLineBufferTransport
which then points to
extern ThingstreamTransportResult Thingstream_line_buffer_deliver(ThingstreamTransport *self);
I have also rebuilt the index multiple times and still no success.
I don't know what else to do to solve this.
I am trying to recompile app_fax.c to app_fax.so (module used by asterisk to send/receive fax under 4PSA system) which needs a header file called 4psa_base.h
The reason I am recompiling this c program is because of a timeout setting inside the program that kills fax calls that last more than 30 minute. what I did was just change that value
I have looked everywhere for this file with no luck. its not anywhere that I can find it.
Is there anyone that may have any clue where to find this file?
Thanks,
Javid
I'm not sure which version of Asterisk you are using, but app_fax (which is not the preferred fax module in Asterisk) depends on spandsp. Looking at the source, it does not include the header file you're referring to:
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <pthread.h>
#include <errno.h>
#include <tiffio.h>
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
#include <spandsp.h>
#include <spandsp/version.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/dsp.h"
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/format_cache.h"
Is this a custom patch to Asterisk?
I have a piece of code that used to work in some environment a long time ago. I'm pretty sure it was a FreeBSD machine so I got FreeBSD 8.3 and I'm trying to make this file but it's not working.
When I try to compile it it complains with:
f.c: In function 'tcp'>
f.c:24: error: storage size of 'socket_stru' isn't known
f.c:29: error: 'IPPROTO_TCP' undeclared (first use in this function)
...
I've been looking around and I see these are all specified in the sys/socket.h file. This is my actual file:
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <sys/socket.h>
#include <unistd.h>
#include "f.h"
int tcp4 (in_addr_t ip, int port, int qsize )
{
struct sockaddr_in socket_stru; // line 24
socket_stru.sin_family = AF_INET;
socket_stru.sin_port = htons(port);
socket_stru.sin_addr.s_addr = ip;
int actual_socket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); // line 29
...
I feel like my code somehow doesn't "read" the sys/socket.h file so it doesn't know about socket_stru and IPPROTO_TCP, but I'm just really lost.
Any ideas?
None of the other answers worked for me. After taking a look inside the sys/socket.h file, I didn't even see a definition for struct sockaddr_in.
What worked for me was to #include one of the following files when using the corresponding struct sockaddr_* type:
if you're using struct sockaddr_in, #include <netinet/in.h>
if you're using struct sockaddr_un, #include <sys/un.h>
if you're using struct sockaddr_ns, #include <netns/ns.h>
if you're using struct sockaddr_ndd, #include <sys/ndd_var.h>
More information on the header files for socket programming can be found here.
I cut and paste your code into a file (removing only the #include f.h and closed off the function call.) It compiles just fine on Linux.
I suspect there may be header files differences on BSD. For socket programming, I typically include ALL these header files. And I know my socket code compiles on BSD as well. I suspect one of these header files brings in the definition for sockaddr_in. I recall when I ported by socket code to BSD, I had to explicitly add a few of these.
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#include <stdlib.h>
#include <memory.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <stdarg.h>
/* the next two includes probably aren't relevant for you, but I typically use them all anyway */
#include <math.h>
#include <sys/termios.h>
Hope this helps
I had the same problem, but the following include fixed the issue for me
#include <arpa/inet.h>
Just add #include <resolv.h> to your source and you are good to go.
According to freebsd developer's handbook you need
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
Everything goes well with this statement:
fnmatch(pattern, href, FNM_EXTMATCH);
when I oder the header files as below:
#include <fnmatch.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "link.h"
But the gcc says that FNM_EXTMATCH not defined when I order the head files instead as below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fnmatch.h>
#include "link.h"
So where is the conflict?
FNM_EXTMATCH is a GNU extension. If you wish to use it, put
#define _GNU_SOURCE
at the top of your file (before any #include statements). Note, however, that it will not be portable to non-GNU systems -- those without gcc and glibc.