201 questions
4
votes
3
answers
178
views
GNU ld - Don't allow multiple definitions (function symbols) or at least warn when found in single archive (*.a)
I have started a bare-metal kernel targeting the AArch64 architecture for the purpose of education. Use a self-written libc for my kernel which includes the basic string functions. Here the functions ...
1
vote
1
answer
95
views
Why does my code give multiple definitions error?
I am trying to build the following code on my computer but I run into a lot of errors. The error says that g_tagParams and g_loggerparams are multiply defined in many of the functions. But these two ...
3
votes
2
answers
222
views
How can multiple definitions in static libraries be detected/prevented?
It is known that some linkers do not report multiple definition errors when there are multiple definitions in static libraries. See for example here: Multiple definition within static library or here: ...
1
vote
0
answers
151
views
multiple definition linker error while compiling project with 'mksquashfs'
I'm encountering a 'multiple definition' error while trying to compile a project that includes "mksquashfs". The error I'm getting are like this:
/usr/bin/ld: read_fs.o:(.bss+0x0): multiple ...
0
votes
1
answer
379
views
Why doesn't defining global `void operator new(std::size size)` cause multiple definition link error? [duplicate]
Why doesn't defining void* operator new(std::size_t) at the global scope cause a multiple definition link error?
E.g. the code below compiles and runs, but I imagine that libstdc++ must define a ...
0
votes
1
answer
186
views
How to undef calloc() function from stdlib to use our own function
I have a header file calloc.h, where I defined calloc() function using stdlib's malloc() function. But I am getting multiple definition of 'calloc' error.
calloc.h:
#include <stdbool.h>
#include ...
-1
votes
1
answer
196
views
Multiple definition error when building SFML project with CMAKE
I am using a static library. But when I want to make a SHARED library, I can't build the projectas I get "multiple definition error"s.
Library CMake:
add_library(arcade-lib SHARED
...
1
vote
1
answer
126
views
Multiple definition error is NOT happening when it should
I have a header header.hxx like this:
// header.hxx
#ifndef HEADER1
#define HEADER1
typedef struct s_ringreader{
// some stuff in header
} RingReader;
RingReader defaultReader;
#endif
and ...
6
votes
1
answer
1k
views
"Multiple definition" error when statically linking
I'm trying to compile a link together these simple example programs:
main.cpp:
#include "server.hpp"
int main()
{
}
server.hpp:
#ifndef SERVER_HPP
#define SERVER_HPP
#include <boost/...
0
votes
1
answer
80
views
Reproducing "multiple declarations" error from linker
So, I was going to demonstrate the problem of (non-template) implementation in C++ .h files to a college.
But right now I can't reproduce it as expected. Here's my code:
// common.h
#ifndef common_h
#...
1
vote
0
answers
85
views
"undefined reference to 'WinMain@16'" when adding SDL2 libraries in C++ environment [duplicate]
I have been trying to get SDL2 to work in my environment but have had no luck. I am using Windows 10 Home with MinGW, working in Eclipse IDE for C/C++ Developers.
I downloaded SDL2.26.4 from this ...
0
votes
1
answer
2k
views
Platformio C++ multiple "multiple definition of"
I can't resolve this problem on my arduino project. I am using Platformio on vscode.
I want to use the MFRC522_I2C library to read rfid badges so I created a class to use the libraries methods.
The ...
0
votes
1
answer
267
views
Multiple definition of short_options and long_options with getopt
I am writing my own implementation of cat and using getopt_long to parse command line arguments.
I have three files: one with function headers, one with function definitions, and one with main.
Here ...
0
votes
0
answers
37
views
Use header-only (+implementation .h files) across multiple files in C++ project [duplicate]
I have been trying to use this library in my C++ project for some time now and can't seem to figure out how to get around the issue of multiple definitions. The library contains only header files (and ...
1
vote
1
answer
369
views
Compilation error when creating ISR(vect) interruption : multiple definition of `TIMER0_COMPA_vect'
Good morning everyone i'm posting this here because i can't figure it out on my own. I've been trying to add ISR function in my project but it doesn't compile.
I work on Microship studio on an ...
0
votes
0
answers
193
views
Multiple definition running MF Media Session Playback Example using Windows SDK 10.0.22000.0
I'm new to Media Foundation, and I downloaded the code from the media session playback example, and the Windows 11 SDK. I used the following makefile to compile with MSYS2 g++:
LDFLAGS = -LC:\\...
0
votes
2
answers
2k
views
Should small utility functions be split into header & source files or just add inline keyword?
I have some small utility functions (< 20 lines of code per function) that I am currently putting in a utils.h file with the keyword inline in front of them so I don't run into multiple definition ...
0
votes
1
answer
445
views
Static Member Initialization and Singleton Design, error -> multiple definition of member
I'm trying to implement singielton design, but unfortunately this error of multiple definiton occurrs. Everything seems to be alright I cannot find multiple definiton nowhere.
I tried to compile it ...
0
votes
1
answer
2k
views
Multiple definition of variable First defined here error
I have this c++ project with classes' definitions inside .hpp files and methods' declarations inside .cpp files.
The project uses a makefile to build and run.
The program ran without errors before but ...
5
votes
1
answer
976
views
How can reordering the linked libraries fix multiple definitions error?
I faced a situation where different order of linking librdkafka and the Pulsar C++ client does matter, because both of them include their version of LZ4 compression. The linking fails because of ...
0
votes
1
answer
420
views
QT multiple definitions
I've been trying to solve this issue and nothing seems to work, tryed clean the project, run qmake, made sure there was no recursive includes between files, but still showing the error.
Also there is ...
0
votes
0
answers
26
views
Operator overloading on the global scope in qt/c++ is giving me the multiple definition compile error [duplicate]
I am a bit new to operator overloading like this.
Very simple code:
#ifndef QTRIGONOMETRY_H
#define QTRIGONOMETRY_H
struct Real
{
double m;
};
double operator-( int n, const Real m ) { return n -...
0
votes
1
answer
1k
views
Preventing multiple definition in C++ [duplicate]
I am getting error:
/usr/bin/ld: /tmp/ccCbt8ru.o: in function `some_function()':
Thing.cpp:(.text+0x0): multiple definition of `some_function()'; /tmp/ccc0uW5u.o:main.cpp:(.text+0x0): first defined ...
0
votes
1
answer
273
views
multiple definition error while compiling tftp-hpa
I wanna compiling tftp-hpa from source code but i get following error:
gcc tftp.o main.o ../common/libcommon.a -lreadline -ltermcap /home/ali/programming/c/opensource/tftp-hpa/lib/libxtra.a -o tftp
...
1
vote
1
answer
733
views
Why am I getting Multiple definition errors while compiling?
I'm trying to do a simple program in Contiki to generate a random number between two numbers and then flash it on a Zolertia module.
My code is:
#include <stdio.h>
#include <stdlib.h>
#...
0
votes
2
answers
417
views
Multiple definition with 2 header files
I am using CodeBlocks.
In C++, I have 3 header files and 3 cpp files like below.
Base.h
class Base
{
public:
virtual int funky(int x, int y);
};
Base.cpp
int funky(int x, int y) {
return x+y;
}...
0
votes
0
answers
336
views
How do I best use #include to prevent my multiple definition error?
While implementing three files (tree.h, tree.cpp, and node.h) into an existing project, I've run into "multiple definition of" errors when trying to reference them in my parser.h and parser....
0
votes
3
answers
959
views
Multiple Definition with Multiple Source Files
I'm currently writing a C program with multiple header and source files.
I have been running into the problem of multiple definition of function foo.
I understand that I am violating the One ...
1
vote
1
answer
2k
views
Compile old C code (on Linux) that throws errors (Multiply defined) with modern gcc? [closed]
Why would I want this?
I'd like to use a C package that was initially built in 2007 and last updated in 2016 according to the Changelog. I gather that it would have compiled cleanly back than.
Sadly, ...
3
votes
1
answer
2k
views
Boost - Multiple definitions during linking
I have these two classes (let's call them A and B) that both include boost/archive and boost/serialization files. These includes are in my hpp files (with header guards) for each of the two classes. ...
0
votes
1
answer
338
views
Multiple definitions for function templates with float, trying to resolve linker error
I'm working on a set of function templates and the compile just fine. You can see them working here on Compiler Explorer... The issue is when I try to use it with T = float within my project, it is ...
0
votes
1
answer
477
views
Include a h file in more than one cpp file [duplicate]
I am currently working on a project that has files (generalFunctions.h and 1x generalFunctions.cpp) that are used by multiple .cpp files. In these files is written
#include "generalFunctions.h&...
-2
votes
2
answers
1k
views
Why can't I initialize a static class member in a common header file?
Suppose I have a header only library. I have simplified it to something like this.
Header only library Foo.hpp
#ifndef FOO_HPP
#define FOO_HPP
struct Foo{
static const int A;
};
const int Foo::A ...
1
vote
1
answer
155
views
How to link all files in C ansi? Error with multiple definition
Good morning
This is big problem for me to link all files (main.c, myFunc.c, myFuncHeaders.h and MakeFile).
Problem is multiple definition when I don't know what should I do with it. I used global ...
1
vote
0
answers
337
views
Multiple defination error while compiling Marlin using platformio
Recently updated to Marlin 2.0.6.1, because the compiler won't work with 2.0.6 anymore. Updated the platformio as well. Now when I compile I get these errors, mostly multiple defination kinds, before ...
1
vote
1
answer
2k
views
Multiple definition error (collect2: error: ld returned 1 exit status)
I was using https://github.com/jdduke/three_cpp as a header-only mode but faced some issues while compiling the same with my project.
The issue happens when I include the following matrix4.hpp header (...
6
votes
0
answers
462
views
What is the meaning of "T" symbol address = 0 in nm output
I have 2 static libraries, that were compiled differently. At this point, I don't understand the difference.
I just want to understand, for the same symbol in one library, the address of the symbol is ...
0
votes
0
answers
145
views
Why do I keep getting Multiple definition error in C++?
I am new to programming in C++ and was wondering if you guys could help me solve this problem. I am doing a program where I have a class for an object that will act as an array.
When I try to compile ...
0
votes
3
answers
468
views
How to solve error of Multiple definition of swap in C
I am getting error 'multiple definition of swap' from swap function. This code is for selection sort.
#include <stdio.h>
#include <string.h>
static void BiDirectionalSelectionSort(int ...
1
vote
0
answers
145
views
VSCode C++: Multiple irrelevant definitions for simple symbols
For example, in some single C++ file, the definitions shown for a simple symbol x relate to many other irrelevant includePaths: Screenshot
How could this be fixed?
-2
votes
1
answer
2k
views
(Makefile Error) Multiple definitions errors
Basically I'm trying to create a makefile for the project I'm currently working on.
The error suggests that I've defined the same function twice in two different files.
The error repeats throughout ...
0
votes
2
answers
83
views
Why can't I declare a variable or function more than once with different types?
Okay I know "One Definition Rule", but when I try to declare a variable with different types subsequently in source code, I run into some mistake like following:
int fkc();
void fkc();
enter image ...
1
vote
2
answers
290
views
How do I partially-expose object contents in an object library?
I'm compiling some C++ code into a library. Suppose my source files are mylib.cpp and util.cpp. The code in util.cpp is used in the library implementation, but is not part of the library in the sense ...
2
votes
1
answer
2k
views
Error multiple definition of struct, but i dont see the error anywhere ( C++ )
made a struct, compiled my program, worked perfectly, didn't change anything, closed vm, restarted vm and vsc, and then did make in console again and it came up with this error
1 warning generated.
...
2
votes
1
answer
417
views
Why does a template specialization require an inline definition? [duplicate]
In the example given in §14.4.1 "Accelerated C++, A. Koenig and B. E. Moo" I have problems if I implement the template specialization like it is presented in the book.
The minimum working example (...
1
vote
0
answers
665
views
Multiple Definition linker error w/ std::__shared_ptr<std::filesystem::__cxx11::_Dir, ... GCC9, C++17
context
OS: Ubuntu 18.04
Build: CMake 3.10.2
Compiler: gcc-9 (Ubuntu 9.2.1-17ubuntu1~18.04.1) 9.2.1 20191102
Configuration: x86_64, debug
action
I upgraded to the aforementioned gcc version and ...
2
votes
1
answer
212
views
Multiple inclusion of GetPot
I'm facing a problem with GetPot (http://getpot.sourceforge.net/), namely the fact that when I include it more than once I get a multiple definition error by the linker.
Here's a MWE:
file main.cpp:
...
0
votes
0
answers
97
views
Multiple definition of functions
I have use 1 header file and 2 code files. One of "multiple definition..." function is duplicate because I use "#ifdef _WIN32 ..." and "#ifdef unix...".
I have error "multiple definition..." in "...
0
votes
2
answers
1k
views
How to allocate a global int* dynamically?
I'm trying to do a Merge Sort code in C++, and to avoid a lot of memory use, I want to declare the auxiliary vector as a global variable. As you might know, using the global variable strategy the ...
0
votes
1
answer
2k
views
Multiple definition of Variable while it is not
I am trying to compile an empty project using MPLAB X IDE. I have just used mcc (microchip code configurator) to make the first configuration of the clock only.
mcc generated a bunch of header files ...