ns modification and compiling error - tcl

i am working on ns-allinone-2.35 . and i modified the aodv protocol that located on /ns-allinone-2.35/ns-2.35/aodv folder. i do make clean , then make, every thing is ok.
but i notice that no changing in the result.
and i notice that if i change all aodv code to comments, the TCL file will running even if delete the aodv.o.
can any one help to specify exactly where is the changing on ns-allinone-2.35? and from where the TCL file read the routing protocol?

»»
the TCL file will running even if delete the aodv.o
««
Files{.cc, .h, .o}, etc. in the ns-2.35/ folder are not used at simulation time. ( Exceptions : Some simulations can/will use some traffic files, e.g. from tcl/mobility/** ).
All functions from the c++ files (and tcl/lib/files*) are compiled into one file : 'ns'.
Files used by the executable 'ns' are the these only :
ns-allinone-2.35/{ lib/**, bin/tclsh8* }.
Changes : Be aware that ns2 speaks "otcl". And that all the (o)tcl functions in tcl/lib/ are also compiled into the executable 'ns'.
So may be your new function is missing in tcl/lib/{ files.tcl } ?

Related

nsys says "please use the qdrep file instead" - huh?

I'm using NVIDIA Nsight Systems version 2019.5.2.16-b54ef97 with CUDA 10.2. I'm running:
nsys profile my_app --some --args=here
so, a plain-vanilla profiling with no funny business. And yet, I get, at the bottom of the output:
... etc. etc. ...
Saving report to file "/some/where/report1.qdrep"
Report file saved.
Please discard the qdstrm file and use the qdrep file instead.
Removed /some/where/report1.qdstrm as it was successfully imported.
Please use the qdrep file instead.
Why am I being told to discard files and use other files instead? Especially given how, eventually, only a single file is generated (a .qdrep file)?
I'm guessing some internal conversion utility is run, and the message is not really intended for me - or am I missing something?
It is just a logging, which is a little confusing though, and later it removes the *.qdstrm file for you automatically.

How to create a "debug" enabled version of a signed native installer?

By adding an empty file called "debug" to the META-INF/AIR folder in an AIR application, it is possible to do all sorts of great things, including the ability to call getStackTrace() on an error event, which could be extremely useful in diagnosing uncaughtErrorEvents. However, try as I may, I can't figure out how to create a signed native installer with the empty "debug" file in this folder.
I have tried including META-INF/AIR/debug in my src directory. When I export the release version and check "keep bin-release-temp folder", the "debug" file is present; however, it's not included in the installer.
I've also tried adding "-debug=true" as an additional compiler argument, but this seems to have no effect.
I've seen some instructions on how to edit and re-sign an ipa. I wonder if there might be a way to do the same thing with my native installer. I think it might involve unzipping it, adding the "debug" folder to META-INF/AIR, and then zipping it back up and signing it. Somehow I think it would be more complicated than this.
For your task I usually use a very powerful debugger called Monster debugger (http://www.demonsterdebugger.com)
You will need to only include their SWC to the source and initialize the debugger somewhere in the beginning of your program. After that you'll have many advanced features available:
tracing objects
pausing program state
changing variables on run-time
and many more.
Check it out, there's a very nice tutorial for it that looks and feels like a game.
Oh, yeah, and it's free too!
You should use conditional compilation. It's great instrument for debugging purposes.
define=NAMESPACE::variable,value
Defines a global constant. The value is evaluated at compile time and exists as a constant within the application. A common use of inline constants is to set values that are used to include or exclude blocks of code, such as debugging or instrumentation code. This is known as conditional compilation.
Example:
-define=CONFIG::DEBUG,true
//In code
CONFIG::DEBUG{
//your code with debugging, logging, whatever
}
If you don't want to work with conditinal compilation and you need some flag in your air application, you could compile your air application with file (xml file is great choice, because there is E4X), in your case, let's call it settings file.
change information in brackets, and remove brackets
"[Path to the FlexSDK]\bin\adt" -package -storetype pkcs12 -keystore "[Path to the Air certificate]\myCert.p12" -storepass [Certificate password] "[Path to result]\myApp.air" "[path to the app descriptor]\my-app.xml" -C "[Path to your stuff]" myApp.swf settings.xml
Organise settings.xml how you want it, set there useful flags, load it in runtime.
private function getSettings():XML{
var fileToCreate : File = File.applicationDirectory;
var stream : FileStream = new FileStream();
var fileData : String;
fileToCreate = fileToCreate.resolvePath("settings.xml");
stream.open(fileToCreate, FileMode.READ);
fileData = stream.readUTFBytes(stream.bytesAvailable);
return new XML(fileData);
}

Failed to create shared library with wx and STL, "multiple definition" error?

I tried to build a shared library using wx and STL, and failed in an error of "multiple definition of". Please refer to:
https://code.google.com/p/gppanel/issues/detail?id=7
The declaration of wxPointListNode is not found in the sources. The suspicious lines are like these:
include/mathplot.h:85:WX_DECLARE_LIST(wxPoint, PointList);
include/mathplot.h:87:WX_DEFINE_LIST(PointList);
include/gpLineLayer.h:16:typedef std::deque<mpPointLayer*> mpPointList_t;
What the problem is?
Without the actual code this is just a guess, but I suspect that
include/mathplot.h:87:WX_DEFINE_LIST(PointList);
generates the full definition of PointList, including a non-templated method wxPointListNode::DeleteData. mathplot.h is included by all of the .cpp files (gpPanel.cpp, gpSeries.cpp, and baseData.cpp). Each cpp file is compiled into a .o file, so each has its own definition of DeleteData, and when you try to link the .o files together into lib/libgpPanel.so the linker issues the errors you're reporting.
The definition of the method needs to be in its own cpp file that's compiled and linked in.
All wxWidgets methods with DEFINE in their name expand into a definition of something and a definition can only be used once in a module, so it typically can't appear in a header file (unless you can guarantee that it's included by only a single source file). So just don't put it there.
Moreover, if this is your code, you should avoid using the legacy WX_DECLARE_LIST macro at all and just use std::list<> or std::vector<> instead. Or, if you really want to use only wx (which can only be important if you are targeting some embedded platform without good STL implementation), then use wxVector<>.

cuPrintf cuda function

I want to use the cuPrintf function, and I get it from SDK. In the readme file they write the following
Use The cuPrintf package consists of two device functions (i.e. called
from within a CUDA kernel) and three host functions (i.e. called from
within the host application). These are packaged in a single
cuPrintf.cu file, along with declarations included in a separate
cuPrintf.cuh header file. To use cuPrintf in your application, you
must do one of the following:
a) Either: Include the header-file cuPrintf.cuh at the top of your
device code, and add cuPrintf.cu to your makefile or build
command-line so that the file is included in your program.
b) Or: Directly “#include cuPrintf.cu” at the top of your device
code. In this case you should not add this file to your
makefile/build-command, and you should take care to only include it
once in your entire project.
I tried some ways but all of them give me error, ( fatal error C1083: Cannot open include file: 'cuPrintf.cuh': No such file or directory )
I put the 'cuPrintf.cu' in the header folder in the VB 2008, and
include but give me error, and change it to
cuPrintf.cuh but also don't work.
I put both files in the extension of the project , and include them
in the code , and also give me error.
Any suggestions about how to fix it, I need this function for my code.
I solved my error , by this way :
put both files ".cu & .cuh" in the same path of the project , and include "cuPrintf.cu" in the top of the code and delete the .cu file from the header
Hope this will help who face the same error

Get the application's path

I've recently searched how I could get the application's directory in Java. I've finally found the answer but I've needed surprisingly long because searching for such a generic term isn't easy. I think it would be a good idea to compile a list of how to achieve this in multiple languages.
Feel free to up/downvote if you (don't) like the idea and please contribute if you like it.
Clarification:
There's a fine distinction between the directory that contains the executable file and the current working directory (given by pwd under Unix). I was originally interested in the former but feel free to post methods for determining the latter as well (clarifying which one you mean).
In Java the calls
System.getProperty("user.dir")
and
new java.io.File(".").getAbsolutePath();
return the current working directory.
The call to
getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
returns the path to the JAR file containing the current class, or the CLASSPATH element (path) that yielded the current class if you're running directly from the filesystem.
Example:
Your application is located at
C:\MyJar.jar
Open the shell (cmd.exe) and cd to C:\test\subdirectory.
Start the application using the command java -jar C:\MyJar.jar.
The first two calls return 'C:\test\subdirectory'; the third call returns 'C:\MyJar.jar'.
When running from a filesystem rather than a JAR file, the result will be the path to the root of the generated class files, for instance
c:\eclipse\workspaces\YourProject\bin\
The path does not include the package directories for the generated class files.
A complete example to get the application directory without .jar file name, or the corresponding path to the class files if running directly from the filesystem (e.g. when debugging):
String applicationDir = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
if (applicationDir.endsWith(".jar"))
{
applicationDir = new File(applicationDir).getParent();
}
// else we already have the correct answer
In .NET (C#, VB, …), you can query the current Assembly instance for its Location. However, this has the executable's file name appended. The following code sanitizes the path (using System.IO and using System.Reflection):
Directory.GetParent(Assembly.GetExecutingAssembly().Location)
Alternatively, you can use the information provided by AppDomain to search for referenced assemblies:
System.AppDomain.CurrentDomain.BaseDirectory
VB allows another shortcut via the My namespace:
My.Application.Info.DirectoryPath
In Windows, use the WinAPI function GetModuleFileName(). Pass in NULL for the module handle to get the path for the current module.
Python
path = os.path.dirname(__file__)
That gets the path of the current module.
Objective-C Cocoa (Mac OS X, I don't know for iPhone specificities):
NSString * applicationPath = [[NSBundle mainBundle] bundlePath];
In Java, there are two ways to find the application's path. One is to employ System.getProperty:
System.getProperty("user.dir");
Another possibility is the use of java.io.File:
new java.io.File("").getAbsolutePath();
Yet another possibilty uses reflection:
getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
In VB6, you can get the application path using the App.Path property.
Note that this will not have a trailing \ EXCEPT when the application is in the root of the drive.
In the IDE:
?App.Path
C:\Program Files\Microsoft Visual Studio\VB98
In .Net you can use
System.IO.Directory.GetCurrentDirectory
to get the current working directory of the application, and in VB.NET specifically you can use
My.Application.Info.DirectoryPath
to get the directory of the exe.
Delphi
In Windows applications:
Unit Forms;
path := ExtractFilePath(Application.ExeName);
In console applications:
Independent of language, the first command line parameter is the fully qualified executable name:
Unit System;
path := ExtractFilePath(ParamStr(0));
Libc
In *nix type environment (also Cygwin in Windows):
#include <unistd.h>
char *getcwd(char *buf, size_t size);
char *getwd(char *buf); //deprecated
char *get_current_dir_name(void);
See man page
Unix
In unix one can find the path to the executable that was started using the environment variables. It is not necessarily an absolute path, so you would need to combine the current working directory (in the shell: pwd) and/or PATH variable with the value of the 0'th element of the environment.
The value is limited in unix though, as the executable can for example be called through a symbolic link, and only the initial link is used for the environment variable. In general applications on unix are not very robust if they use this for any interesting thing (such as loading resources). On unix, it is common to use hard-coded locations for things, for example a configuration file in /etc where the resource locations are specified.
In bash, the 'pwd' command returns the current working directory.
In PHP :
<?php
echo __DIR__; //same as dirname(__FILE__). will return the directory of the running script
echo $_SERVER["DOCUMENT_ROOT"]; // will return the document root directory under which the current script is executing, as defined in the server's configuration file.
echo getcwd(); //will return the current working directory (it may differ from the current script location).
?>
in Android its
getApplicationInfo().dataDir;
to get SD card, I use
Environment.getExternalStorageDirectory();
Environment.getExternalStoragePublicDirectory(String type);
where the latter is used to store a specific type of file (Audio / Movies etc). You have constants for these strings in Environment class.
Basically, for anything to with app use ApplicationInfo class and for anything to do with data in SD card / External Directory using Environment class.
Docs :
ApplicationInfo ,
Environment
In Tcl
Path of current script:
set path [info script]
Tcl shell path:
set path [info nameofexecutable]
If you need the directory of any of these, do:
set dir [file dirname $path]
Get current (working) directory:
set dir [pwd]
Java:
On all systems (Windows, Linux, Mac OS X) works for me only this:
public static File getApplicationDir()
{
URL url = ClassLoader.getSystemClassLoader().getResource(".");
File applicationDir = null;
try {
applicationDir = new File(url.toURI());
} catch(URISyntaxException e) {
applicationDir = new File(url.getPath());
}
return applicationDir;
}
in Ruby, the following snippet returns the path of the current source file:
path = File.dirname(__FILE__)
In CFML there are two functions for accessing the path of a script:
getBaseTemplatePath()
getCurrentTemplatePath()
Calling getBaseTemplatePath returns the path of the 'base' script - i.e. the one that was requested by the web server.
Calling getCurrentTemplatePath returns the path of the current script - i.e. the one that is currently executing.
Both paths are absolute and contain the full directory+filename of the script.
To determine just the directory, use the function getDirectoryFromPath( ... ) on the results.
So, to determine the directory location of an application, you could do:
<cfset Application.Paths.Root = getDirectoryFromPath( getCurrentTemplatePath() ) />
Inside of the onApplicationStart event for your Application.cfc
To determine the path where the app server running your CFML engine is at, you can access shell commands with cfexecute, so (bearing in mind above discussions on pwd/etc) you can do:
Unix:
<cfexecute name="pwd"/>
for Windows, create a pwd.bat containing text #cd, then:
<cfexecute name="C:\docume~1\myuser\pwd.bat"/>
(Use the variable attribute of cfexecute to store the value instead of outputting to screen.)
In cmd (the Microsoft command line shell)
You can get the name of the script with %* (may be relative to pwd)
This gets directory of script:
set oldpwd=%cd%
cd %0\..
set app_dir=%pwd%
cd %oldpwd%
If you find any bugs, which you will. Then please fix or comment.
I released https://github.com/gpakosz/whereami which solves the problem in C and gives you:
the path to the current executable
the path to the current module (differs from path to executable when calling from a shared library).
It uses GetModuleFileNameW on Windows, parses /proc/self/maps on Linux and Android and uses _NSGetExecutablePath or dladdr on Mac and iOS.
Note to answer "20 above regarding Mac OSX only: If a JAR executable is transformed to an "app" via the OSX JAR BUNDLER, then the getClass().getProtectionDomain().getCodeSource().getLocation(); will NOT return the current directory of the app, but will add the internal directory structure of the app to the response. This internal structure of an app is /theCurrentFolderWhereTheAppReside/Contents/Resources/Java/yourfile
Perhaps this is a little bug in Java. Anyway, one must use method one or two to get the correct answer, and both will deliver the correct answer even if the app is started e.g. via a shortcut located in a different folder or on the desktop.
carl
SoundPimp.com