Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic undefined reference to BridgeServer (Read 5665 times)
peter_chb
Newbies
*
Offline


Posts: 5
Joined: Feb 16th, 2018
undefined reference to BridgeServer
Feb 16th, 2018 at 4:50pm
Print Post  
Hi,

I just have started to use Visual Micro under VS 2015. And I run into a problem, when I compile this sketch under arduino IDE it does not bring error, but under Visual Micro yes. Error report is the following:

Compiling debug version of 'test_lib_sketch' for 'Arduino Mega 2560 - Dragino Yún'
ld.exe: BridgeServer.cpp.o: plugin needed to handle lto object

Error linking for board Arduino Mega 2560 - Dragino Yún
Debug build failed for project 'test_lib_sketch'
 
ccfYngTe.ltrans0.ltrans.o*: In function global constructors keyed to 65535_0_test_lib_sketch.cpp.o.2476
ccfYngTe.ltrans0.o*: (.text.startup+0x144): undefined reference to BridgeServer::BridgeServer(unsigned int, BridgeClass&)
 
collect2.exe*: error: ld returned 1 exit status


What am I trying to do is to create a user library and in the Library I create a BridgeServer object. I tried to use normal text editor way to create a library and also with VM and add in the reference

My header file is:
Code (C++)
Select All
/*
 Name:		test_lib.h
 Created:	2/16/2018 5:13:35 PM
 Author:	Winkler Peter
 Editor:	http://www.visualmicro.com
*/

#ifndef _test_lib_h
#define _test_lib_h

#if defined(ARDUINO) && ARDUINO >= 100
	#include "arduino.h"
#else
	#include "WProgram.h"
#endif

#include <Bridge.h>
#include <Console.h>
#include <BridgeServer.h>
#include <BridgeClient.h>

#endif

class CommunicationClass
{
public:
	//members
	BridgeServer Server;

	//methods
	CommunicationClass(uint16_t port);
	~CommunicationClass();

private:

}; 



My cpp file is:
Code (C++)
Select All
/*
 Name:		test_lib.cpp
 Created:	2/16/2018 5:13:35 PM
 Author:	Winkler Peter
 Editor:	http://www.visualmicro.com
*/

#include "test_lib.h"



CommunicationClass::CommunicationClass(uint16_t port):
	Server(port)
{
}

CommunicationClass::~CommunicationClass()
{
} 



and my sketch is the following:
Code (C++)
Select All
/*
 Name:		test_lib_sketch.ino
 Created:	2/16/2018 3:44:26 PM
 Author:	Winkler Peter
*/

#include "test_lib.h"

CommunicationClass Communication(7777);

// the setup function runs once when you press reset or power the board
void setup() {

}

// the loop function runs over and over again until power down or reset
void loop() {
 
} 



I'm quite new in the topic, so it could be that I miss a lot of things to understand, but I'm stucked at this point.

It would be greatfull, if someone could help me out.
Thank you,
Peter
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to BridgeServer
Reply #1 - Feb 16th, 2018 at 5:07pm
Print Post  
Hi,

Does the project build in the arduino ide?

Please zip the project folder and attach to this thread thanks
  
Back to top
IP Logged
 
peter_chb
Newbies
*
Offline


Posts: 5
Joined: Feb 16th, 2018
Re: undefined reference to BridgeServer
Reply #2 - Feb 16th, 2018 at 8:11pm
Print Post  
Hi,

Yes in Arduino IDE the project build without problem.

I'm writing now from another workstation and I get here almost the same errors.

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to BridgeServer
Reply #3 - Feb 17th, 2018 at 1:03pm
Print Post  
The zip does not contain valid source code or valid project files

Please zip the sketch folder you used when testing with the arduino ide

Thanks

  
Back to top
IP Logged
 
peter_chb
Newbies
*
Offline


Posts: 5
Joined: Feb 16th, 2018
Re: undefined reference to BridgeServer
Reply #4 - Feb 19th, 2018 at 1:06pm
Print Post  
Hi,

Sorry for the previous one, hope this will contain everything you need.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to BridgeServer
Reply #5 - Feb 19th, 2018 at 9:28pm
Print Post  
Hi,

There is some confusion simply because of folder structure.

You actually have an arduino project with an .ino and in a sub folder below that you have some cpp files that you are trying to design into an external arduino library 

The two things are different. 

External arduino libraries do not know about the project code and are located outside (not below) any specific project. They can be shared with multiple projects.

You have also attempted to open the library as a visual studio shared project as opposed to including the source code in your single visual studio project.

I suggest you delete all non source code files from your project folder and sub folder and then use file>open>arduino project to open the .ino and have visual micro create you a new project along with the source code.

When you have your project with the .ino file in it use the solution explorer (little show all files button above it) to right click your .h and .cpp so they are "included in the project". 

When you have one simple project with your 3 source files included in the solution explorer you can build like the arduino ide. The arduino ide does not give ability to include shared projects and include/exclude sources from projects. Therefore it just compiles everything it find in and below the project folder which is why it works but that's confusing when you consider how VS works.

When you are comfortable with a normal arduino project then move on to understanding how to build an arduino library and where to locate it.

nb: A library will never contain an .ino file and will adhere to official arduino folder structure.
« Last Edit: Feb 19th, 2018 at 9:30pm by Tim@Visual Micro »  
Back to top
IP Logged
 
peter_chb
Newbies
*
Offline


Posts: 5
Joined: Feb 16th, 2018
Re: undefined reference to BridgeServer
Reply #6 - Feb 20th, 2018 at 9:29am
Print Post  
Hi,

I'm sorry but in the previous rar I was a little bit lazy and it didn't show the real data structure, but I have the following:
Arduino project file location: Documents\Arduino\test_lib_sketch\test_lib_sketch.ino
Arduino libary location: Documents\Arduino\libraries\test_lib\test_lib.cpp
Documents\Arduino\libraries\test_lib\test_lib.h

I tried your suggested method step by step. In Visual Studio use 'File>Open>Arduino Project' to open the project file (ino) and than in Solution explorer I see my test_lib_sketch.ino file and under External Dependencies I see my test_lib.h library source code. 

After compiling I get the same error message as before.

I'm sorry for the misunderstandings, I'm little bit rookie in the topic.

Thanks
  
Back to top
 
IP Logged
 
peter_chb
Newbies
*
Offline


Posts: 5
Joined: Feb 16th, 2018
Re: undefined reference to BridgeServer
Reply #7 - Feb 20th, 2018 at 9:30am
Print Post  
I made a new rar, which shows my real data structure.

Thanks again,
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint