Compiler gcc:error; no such file or directory

I am extremely new to programming and I am having problems with the basic starting program of, ‘hello, world’. I have downloaded MinGW and I believe I set it up correctly with the command promt by entering: setx PATH “%PATH%;C:\MinGW\bin” Then I created this code following a guide while using Notepad++ saving it under c:/code/c/hello.c … Read more

I don’t understand -Wl,-rpath -Wl,

The -Wl,xxx option for gcc passes a comma-separated list of tokens as a space-separated list of arguments to the linker. So eventually becomes a linker call In your case, you want to say “ld -rpath .“, so you pass this to gcc as -Wl,-rpath,. Alternatively, you can specify repeat instances of -Wl: Note that there is no comma between aaa and the second -Wl. Or, in … Read more

GCC: Array type has incomplete element type

It’s the array that’s causing trouble in: The second and subsequent dimensions must be given: Or you can just give a pointer to pointer: However, although they look similar, those are very different internally. If you’re using C99, you can use variably-qualified arrays. Quoting an example from the C99 standard (section §6.7.5.2 Array Declarators): Question … Read more

Linker error: “linker input file unused because linking not done”, undefined reference to a function in that file

I think you are confused about how the compiler puts things together. When you use -c flag, i.e. no linking is done, the input is C++ code, and the output is object code. The .o files thus don’t mix with -c, and compiler warns you about that. Symbols from object file are not moved to other object files like that. All object … Read more

Telling gcc directly to link a library statically

Use -l: instead of -l. For example -l:libXYZ.a to link with libXYZ.a. Notice the lib and .a are written out, as opposed to -lXYZ which would auto-expand to libXYZ.so/libXYZ.a. It is an option of the GNU ld linker: -l namespec … If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a. … on ELF … systems, ld will search a directory … Read more

typedef fixed length array

The typedef would be However, this is probably a very bad idea, because the resulting type is an array type, but users of it won’t see that it’s an array type. If used as a function argument, it will be passed by reference, not by value, and the sizeof for it will then be wrong. A better … Read more