Thread: LD error - Multiple definition of 'UT_BITS_ADDRESS' / Previous Definition here

  1. #1
    Registered User
    Join Date
    Nov 2008
    Location
    Santa Catarina - Brasil
    Posts
    184

    LD error - Multiple definition of 'UT_BITS_ADDRESS' / Previous Definition here

    main.c
    Code:
    #include "ServerModbus.h"
    
    void* ThreadEntrada(void *arg);
    void* ThreadSaida(void *arg);
    
    int main(int lArgc, char *pcArgv[])
    {
    	SocketModbusStart();
    ServerModbus.h
    Code:
    #ifndef SERVERMODBUS_H_
    #define SERVERMODBUS_H_
    
    #include "ModbusOptions.h"
    
    int SocketModbusStart();
    
    #endif /* SERVERMODBUS_H_ */
    ServerModbus.c
    Code:
    #ifndef SERVERMODBUS_H_
    #define SERVERMODBUS_H_
    
    #include "ModbusOptions.h"
    
    int SocketModbusStart();
    
    #endif /* SERVERMODBUS_H_ */
    ModbusOptions.h
    Code:
    #ifndef MODBUSOPTIONS_H_
    #define MODBUSOPTIONS_H_
    
    	/* Constants defined by configure.ac */
    	#define HAVE_INTTYPES_H @HAVE_INTTYPES_H@
    	#define HAVE_STDINT_H @HAVE_STDINT_H@
    
    	#ifdef HAVE_INTTYPES_H
    		#include <inttypes.h>
    	#endif
    
    	#ifdef HAVE_STDINT_H
    		# ifndef _MSC_VER
    			# include <stdint.h>
    		# else
    			# include "stdint.h"
    		# endif
    	#endif
    
    	#define SERVER_ID         17
    	#define INVALID_SERVER_ID 18
    
    	const uint16_t UT_BITS_ADDRESS = 0x130;
    	const uint16_t UT_BITS_NB = 0x25;
    	const uint8_t UT_BITS_TAB[] = { 0xCD, 0x6B, 0xB2, 0x0E, 0x1B };
    
    	const uint16_t UT_INPUT_BITS_ADDRESS = 0x1C4;
    	const uint16_t UT_INPUT_BITS_NB = 0x16;
    	const uint8_t UT_INPUT_BITS_TAB[] = { 0xAC, 0xDB, 0x35 };

    Error Output
    Code:
    15:18:19 **** Incremental Build of configuration Debug for project AngstromGPIO ****
    make all 
    Building file: ../src/ServerModbus.c
    Invoking: Cross GCC Compiler
    arm-angstrom-linux-gcc -O0 -g3 -Wall -c -fmessage-length=0 -mfloat-abi=hard -mfpu=neon --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi -pthread -lpthread -MMD -MP -MF"src/ServerModbus.d" -MT"src/ServerModbus.o" -o "src/ServerModbus.o" "../src/ServerModbus.c"
    Finished building: ../src/ServerModbus.c
     
    Building target: AngstromGPIO
    Invoking: Cross GCC Linker
    arm-angstrom-linux-gcc -mfloat-abi=hard -mfpu=neon --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi -pthread -lpthread -lmodbus -o "AngstromGPIO"  ./src/AngstromGPIO.o ./src/ServerModbus.o ./src/apiSysClass.o   
    /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/6.2.1/real-ld: error: ./src/ServerModbus.o: multiple definition of 'UT_BITS_ADDRESS'
    /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/6.2.1/real-ld: ./src/AngstromGPIO.o: previous definition here
    Last edited by Salem; 05-10-2017 at 12:45 AM. Reason: fixed tags

  2. #2
    Registered User
    Join Date
    Jun 2015
    Posts
    1,643
    The error says that the value UT_BITS_ADDRESS is defined in more than one object file. It should only be defined in one object file. Presumably both ServerModbus.c and AngstromGPIO.c include ModbusOptions.h, which defines that value (amongst others).

    Is this someone else's code that you are tinkering with?

  3. #3
    Registered User
    Join Date
    Nov 2008
    Location
    Santa Catarina - Brasil
    Posts
    184
    Sorry guys,

    At ServerModbus.h don't need #include "ModbusOptions.h"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiple Definition error
    By thriller500 in forum C Programming
    Replies: 2
    Last Post: 06-09-2012, 04:02 AM
  2. Replies: 3
    Last Post: 02-25-2012, 10:27 AM
  3. Multiple Definition Error
    By ineedmunchies in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2011, 08:54 AM
  4. Multiple definition error, one definition
    By frog in forum C++ Programming
    Replies: 9
    Last Post: 10-21-2010, 03:15 AM

Tags for this Thread