Makefile help MOD5441X!

Discussion to talk about software related topics only.
Post Reply
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

Makefile help MOD5441X!

Post by sblair »

I'm running into some issues when trying to build from a makefile. I've normally always used Eclipse, but am setting up a build server so now need to use Makefile for that.

The build coming from Eclipse runs fine. The build coming from make crashes hard. The following is what I get out the serial port:

Code: Select all

Netburner MCF5441x Alternate Image Monitor V1.03 Oct 26 2013 16:25:49
HELP for help
nb>Waiting 2sec to start 'A' to abort
terminate called after throwing an instance of 'std::length_error'
                                                                    what():  bas
ic_string::_S_create
Everything appears to compile fine with both. Comparing map files didn't offer any big insights either.

I stole the makefile straight from an example project and included ALL of my .cpp files in it.

Code: Select all

NAME = Pathfinder
PLATFORM = MOD5441X



CXXSRCS = \
          Display.cpp \
          DmxParseImagePro.cpp \
          Encore.cpp \
          web.cpp \
          DmxParse.cpp \
          DisplayCalls.cpp \
          SierraRouter.cpp \
          DisplayMenuMap.cpp \
          DmxTimer.cpp \
          SLP.cpp \
          IOExpander.cpp \
          Reveal.cpp \
          DmxParseEncore.cpp \
          ExtronRouter.cpp \
          RevealResolutions.cpp \
          DmxParseSierraRouter.cpp \
	  GMT/GMTNet.cpp \
          GMT/AntennaLink.cpp \
          GMT/TransmitMessage.cpp \
          GMT/GMTmain.cpp \
          GMT/ftps.cpp \
          Serial.cpp \
          RDMReveal.cpp \
          RDM.cpp \
          DmxParseExtronRouter.cpp \
          main.cpp \
          RS485.cpp \
          RDMnet.cpp \
          Dmx_Rdm.cpp \
          DmxParseGMT.cpp \
          ImagePro.cpp \
          FlashSettings.cpp \
          AjaxFramework/TcpServerReset.cpp \
          AjaxFramework/Startup.cpp \
          AjaxFramework/Debug.cpp \
          AjaxFramework/HtmlCCallbacks.cpp \
          AjaxFramework/HtmlServices.cpp \
          AjaxFramework/ServiceProvider.cpp \
          AjaxFramework/TcpServer.cpp \
          RS485TxEn.cpp \
          Switches.cpp \
          ArtNet.cpp \

CSRCS = \

CXXSRCS += htmldata.cpp
CREATEDTARGS = htmldata.cpp

include $(NBROOT)/make/main.mak

htmldata.cpp : $(wildcard html/*.*)
	comphtml html -ohtmldata.cpp
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: Makefile help MOD5441X!

Post by pbreed »

Add the following lines to your make file...
SET FULLCPP=1

by default RTTI and exceptions are turned off.... to save space if your using C++ std library then you need to turn them on...

You may also need to add...

EXTRADBCXXFLAGS = -fexceptions
EXTRACXXFLAGS = -fexceptions




Paul
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

Re: Makefile help MOD5441X!

Post by sblair »

I tried adding those lines in but still the same result. I went ahead and created a support ticket and attached my full project if someone there can take a look. Looking through the make files in all the examples I can't see where there should be any difference. It's ticket #33730

Thanks!
Scott
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

Re: Makefile help MOD5441X!

Post by sblair »

Tod,

Hope you're around here. So we've narrowed it down to the Ajax library code that I'm using from you since that exceptions and STL in it. When I pull that out, then it runs okay under a commandline make.

Do you have an example Make file for how you build projects with the Ajax lib code included in it? I'm pretty certain we are missing something inside the makefile.

Thanks.
Scott
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Makefile help MOD5441X!

Post by tod »

Sorry about the slow response, the forum wouldn't allow me to log in for several days.

It doesn't appear to me you are having a build problem. You're just seeing an uncaught exception. My primary piece of advice is just add some high level catches and narrow in on the problem. Having an uncaught exception is much easier to track down than a random trap.

I would suspect you're seeing an array out of bounds problem, probably on a string array.
Did you modify any of the AJAX code? I tend to prefer vectors over raw arrays and I tend to use checked access methods.
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

Re: Makefile help MOD5441X!

Post by sblair »

Here's the thing. When I run compiled from Eclipse it works fine, as it has for a couple years now. When I run from the make file build it crashes on startup because of the exception, so there are definitely differences in the build.

I don't believe I modified any of the Ajax code. Just added in my own vars.
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

Re: Makefile help MOD5441X!

Post by sblair »

Huge thanks to Forrest for getting to the bottom of this.

As is usual, in the end the problem had nothing to do with what it appeared. Building with the makefile just seemed to exploit a Heisenbug that appears to have been present in the AJAX library code from Tod. I'm not sure if this may have been a result of something I edited a long time ago or was always present.

I tried Forrest's suggestion below and it appears to solve it. Tod, if you're around can you comment if you see other negative results from this?

In htmlservices.cpp, you see the line:

const string HtmlServices::_requestToken = "request";

and in

Code: Select all

HtmlServices::HtmlServices()
{
 AjaxCommands.insert(make_pair(_requestToken+"=machinestate", 
&WriteJsonMachineState));
 AjaxCommands.insert(make_pair(_requestToken+"=sampleData", 
&WriteSampleJsonData));
 AjaxCommands.insert(make_pair(_requestToken+"=debugOptions", 
&WriteDebugOptionsJsonData));

}
the _requestToken object is used. The problem is, at this time _requestToken is
null. The HtmlService object is created before the _requestToken object. When
that constructor is run, _requestToken is null, which gives you that error you
were seeing.

Either requestToken needs to be created before the htmlservice object, or you
move requestToken creation in to the HtmlServices constructor. I did this:

Code: Select all

 const string _requestToken("request");
 AjaxCommands.insert(make_pair(_requestToken+"=machinestate", 
&WriteJsonMachineState));
 AjaxCommands.insert(make_pair(_requestToken+"=sampleData", 
&WriteSampleJsonData));
 AjaxCommands.insert(make_pair(_requestToken+"=debugOptions", 
&WriteDebugOptionsJsonData));

}
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: Makefile help MOD5441X!

Post by pbreed »

The build /link order is probably different between eclipse and makefile...
So the static objects get "built" in a different order...

That explains the difference, but Forrest found the root problem.
Post Reply