I downloaded tdm gcc 10.3.0 and installed it succesfully. I have a file I want to compile yet it is missing header files. Is there a way to add components to tdm gcc from an interface, or do I download the files(headers) manually and add them to the project. If so, where do I add them in the project ? I know header files exist in C:\TDM-GCC-32\include
Also, just in case, I have these header files in my main.c,
#include <winsock2.h>
#include <Windows.h>
#include <ws2ipdef.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <bcrypt.h>
#include <wincrypt.h>
#include <sysinfoapi.h>
#include <winternl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
as i tried to compile with gcc main.c, I got this error
main.c:8:10: fatal error: ws2ipdef.h: No such file or directory
8 | #include <ws2ipdef.h>
| ^~~~~~~~~~~~
compilation terminated.
How can I find this header file? If I just find it in github is it enough to add it to C:\TDM-GCC-32\include ?
another way to ask, how can I add ws2 to tdm gcc, or how to install tdm gcc alongwith?
Related
I'm trying to run a Visual Studio cpp project created by a friend of mine. I'm trying to run the file without VS. But I'm getting a list of errors, all in the same format:
inlining failed in call to always_inline '__m256d _mm256_broadcast_sd(const double*)': target specific option mismatch|
It runs correctly in VS with release mode and breaks when run in debug mode.
The includes are as follows:
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <vector>
# include <omp.h>
#include <chrono>
#include <fstream>
#include <algorithm>
#include <immintrin.h>
using namespace std::chrono;
using namespace std;
and the error is called from here:
double zero = 0;
__m256d acc = _mm256_broadcast_sd(&zero);
Update:
I'm using the this command to run it: g++ -std=c++0x multip.cpp -o multip, is there an additional parameter to add -mavx to the compiler invocation?
"Target specific option mismatch" means that you're missing a feature flag from your GCC invocation. You probably need to add -mavx to your compiler invocation.
If you're intending to run this on your computer only, -march=native will turn on all the feature flags that your own machine supports.
C pre processor not processing header files includes in form #include . It gives error: No such file or directory. The files that are included in form #include "header.h" are pre processed properly. How do solve this. I am using command:
cpp -P -I.PWD file.c
#include "filename" is different from #include <filename>.
See (What is the difference between #include <filename> and #include "filename"?). `
Gist: #include <filename> does NOT search in ..
I have a program written in C which uses the following libraries:
#ifdef _WIN32
#include <winsock2.h>
#define socklen_t int
#else
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
In Windows, in order to compile this program with gcc, you had to use -lWs2_32 property.
How to compile it using gcc in linux?
-lWs2_32 is a linker option to specify a library to link. The compiler does not use it.
For gcc under Linux there is no need to explicitly specify a library when using socket functions.
I think you should statically link the executable and use MinGW. But it's just an assumption. Never tried it.
-lWs2_32 is a linker option to specify a library to link. The compiler does not use it.
For gcc under Linux there is no need to explicitly specify a library when using socket functions.
I am including a few header files:
#include <gsl/gsl_machine.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_cdf.h>
#include <gsl/gsl_cblas.h>
#include <gsl/gsl_sf_gamma.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_linalg.h>
#include <R.h>
#include <Rmath.h>
#include <Rembedded.h>
#include <Rdefines.h>
#include <R_ext/Lapack.h>
#include <R_ext/Linpack.h>
I am able to link the blas and gsl libraries using the following command (the -lm is for math?):
gcc -arch x86_64 myfile.c -o myfile -lgsl -lm -lgslcblas
But I get error:
myfile.c:21:15: error: R.h: No such file or directory
myfile.c:22:19: error: Rmath.h: No such file or directory
myfile.c:23:23: error: Rembedded.h: No such file or directory
myfile.c:24:22: error: Rdefines.h: No such file or directory
myfile.c:25:26: error: R_ext/Lapack.h: No such file or directory
myfile.c:26:27: error: R_ext/Linpack.h: No such file or directory
How do I link the header files when compiling my C code?
Header files aren't linked, only included. The errors mean just what they say: the compiler can't find them. Make sure they are in the standard include directory. Maybe you didn't make install the R library. If the header files are in the same directory as your other source files include them with double-quotes instead of angle brackets:
#include "R.h"
You can add other directories to the list of standard include directories with the -I flag to GCC.
I am making these inclusions:
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
But still getting this warning.
You are probably passing the "-ansi -Wall" switches to the gcc compiler.
You can remove "-ansi" if you don't need it, otherwise try to set the proper feature define macro.
Something like:
#define _POSIX_SOURCE
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
You can also define it on the compile time by adding this flag with gcc.
-D_POSIX_C_SOURCE
ex:
-g -D_POSIX_C_SOURCE -Wall -std=c99
According to the kill(2) Linux manual page, _POSIX_C_SOURCE must be #defined before any includes in order for the prototype of the function kill() to be included through <signal.h> if you are using glibc.
Your code will probably compile either way, since the binary is available for linking regardless of the defines, but that's the proper way to silence this warning according to the documentation.