How do I install a type library to the activex palette via command line for BCB5? - command-line

I can import a type library via tlibimp.exe, but when I open up the IDE, the libraries are not in the activex pallete. I can't seem to figure how to get it to install to a particular package either. In the IDE there is an install button in the Import Type Library dialog. How do I do this in the command line?
When I look in at the OCX.cpp file generated by tlibimp in the CBuilder5\Imports folder, I see "Errors: Error creating palette bitmap of (TTVBH3D) : No Server registered for this CoClass". Does this have something to do with the problem?
Edit:
I want to be able to install components to the activex palette without going through the IDE so that the process can be automated during a build. Any solutions must be able to be fully automated.

According to the parameter options of tlibimp.exe, there is a -Ha+ parameter which will "Generate IDE component wrappers for controls".
There is also a -Hr+ which generates the IDE registration for component wrappers.
Does supplying any of these parameters make any difference?
Not sure from this whether or not you then have to install the components using the generated registration code.

First, run tlibimp.exe (found under Program Files\Borland\C++Builder\Bin) with the ocx\dll you want to install.
Second, locate the cpp file generated by tlibimp (you can specify the output path with tlibimp) and find the string "Servers" at the bottom of the file and replace it with "ActiveX". This string determines the palette to install to. I'm not sure if this can be specified with tlibimp, but it doesn't look like it.
Next, compile the package that contains type library\activex component.
Finally, add a key to the registry. The key goes under HKCU\Software\Borland\C++Builder\5.0\Knownpackages. The name of the key should be the path to package that you just compiled (for example, $(BCB)\Bin\applet50.bpl).
When you open up BCB, you will see the components under the activex palette.
This is the only way I could find to do this that could be automated.

Related

How can one preview the source code of a library in CoDeSys 2.3

Is there any way to preview the source code of an imported library in CoDeSys 2.3? When I check the library *.lib file I can see it is not compiled nor obfuscated, but in the CoDeSys there is no option to get into it.
I've been browsing the web for the answer, but couldn't find anything meaningful.
Technically it is possible to open a "*.lib" file in the Codesys 2.3 IDE if it is not encrypted, but I know that the IDE is customized according to the vendor. For example, I don't have "native Codesys 2.3" (directly provided by 3S Software) installed on my computer, but a version of SEW Eurodrive (PLC Editor), which contains some modifications dedicated to their PLCs. This version allows me to open *.lib files:
Maybe the version you have doesn't allow this.
Here's a way to test it:
If you create a project, add some function blocks and select "Save As" you will see that there are several options:
If you select one of the "Encrypted" options you will immediately be asked to enter a key, which will be prompted when opening the *.lib file.

How to install typings for Visual Studio Code in an offline development environment?

I'm using VisualStudio Code, and trying to enable IntelliSense. It seems to be dependent on typings. How can I install these offline? In PowerShell, running
typings search leaflet
returned an error (unsurprising, because I'm offline).
Unable to connect to "https://api.typings.org/search?query=leaflet"
Running that web query on an online computer resulted in a difficult to read JSON file. A further google search resulted in this likely candidate:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/leaflet/index.d.ts
My question has three parts, and I'd appreciate pointers on any of these.
1) How can I figure out what typings I need?
2) Which files do I need to take to the offline computer? Do I just need the d.ts file?
2) Where should this file be installed so that VS Code can read it?
1) Simply put: if your Visual Studio Code is complaining about not being able to resolve something. Lets say I'm working with jQuery, I'm using $ a lot in my project and it's going to give me an error because it's not Typescript/JavaScript.
To resolve this, I create a JSON file to the root of my project called typings.json. It will look like this:
{
"resolution": "typings/",
"globalDependencies": {
"jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/index.d.ts"
}
}
Then in the Terminal tab (CTRL + SHIFT + <) execute the following command:
typings install
Now it will download the required typings and put the contents to root/typings/. You'll need to reference it in each file you're using (in this case) jQuery in by adding the following to the top of your TS file:
/// <reference path="./typings/globals/jquery/index.d.ts" />
You can also create a definition (.d.ts) file in the root/typings folder and add all the references there so you only have to reference that file.
2) After installing the typings in the previous step, you can copy the typings folder and put it on your offline computer. It's as easy as that. You don't need other files (not even the typings.json file, if you wish).
2) You need to reference definition (d.ts) files at the top of your .ts files.

How to get Google Protobuf working in Matlab?

So if one was to want to use Google protocol buffers in Matlab and using a Windows computer what would be the best way to do that since Matlab is not in the list of supported languages?
I haven't seen an answer on this and I thought the solution was a bit obscure so I am going to post a how to for matlab_out using the protoc.exe
A how to for google protocol buffer matlab out, this is using resources from the internet I will also include a zip file containing all this already done.
Unzip protobuf-‘version#’.zip (looks like: protobuf-#.#.#)
Open file protobuf-#.#.# -> src
Choose your favorite editor (Notepad++ is good) and change Makefile.am (do not include quotes)
a. Under “nobase_include_HEADERS =”
and below “$(GZHEADERS)”
add the line “farsounder/protobuf/compiler/matlab/matlab_generator.h \” (Note the back slash)
b. Under “libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la”
add lines
“farsounder/protobuf/compiler/matlab/matlab_generator.cc \”
“farsounder/protobuf/compiler/matlab/matlab_plugin.cc \”
c. Save the file and exit out
While still in the src directory go into ->google ->protobuf->compiler and change main.cc
a. Under “#include <google/protobuf/compiler/java/java_generator.h>”
add the line “#include <farsounder/protobuf/compiler/matlab/matlab_generator.h>”
b. In main function add the lines
“// Proto2 Matlab
farsounder::protobuf::compiler::matlab::MatlabGenerator matlab_generator;
cli.RegisterGenerator("--matlab_out", &matlab_generator,
"Generate Matlab M files.");”
c. Save the file and exit out
Unzip protobuf-matlab
Open file protobuf-matlab ->src and copy the farsounder directory to protobuf-#.#.# -> src directory
Go back to protobuf-#.#.# directory and into -> vsprojects and open protobuf.sln in Visual Studio, I believe any version should work
There should be a popup that wants to convert the solution file to a more updated version, go ahead and do that
If you do not see solutions explorer open it up using ctrl+alt+L
Open a new windows explorer and go into protobuf-#.#.# ->src->farsounder->protobuf->compiler->matlab, now in visual studio using the solutions explorer expand the libprotoc->Header Files, now in windows explorer copy the matlab_generator.h file and paste it into the Header Files directory
Still in Solutions explorer go into the Source Files directory and copy in the matlab_generator.cc
Contract libprotoc and right click on protoc and click on properties
Under Configuration Properties->Linker->General, Edit Enable Incremental Linking to be No
Under Configuration Properties->Linker->Input, Edit Additional Dependencies
a. Add the lines “Release\libprotobuf.lib” and underneath “Release\libprotoc.lib”
b. Click OK on the Additional Dependencies window and OK on the protoc Property Page
Change the build type to Release
Right-click on libprotobuf and select build, once completed right-click on libprotoc and select build
Once completed right-click on protoc and select build, it should provide you with an protoc.exe under protobuf-#.#.# ->vsprojects->Release, this will now allow you to create matlab .m files by using the matlab_out command
Help to find protobuf-#.#.# and the protobuf-matlab:
Follow these links:
https://code.google.com/p/protobuf-matlab/source/browse/
download the zip file
https://github.com/google/protobuf/releases
download the source code
Extra help, for using protoc.exe
Copy and paste the created protoc.exe to where your .proto file is
Run cmd and change the directory to where your protoc.exe and .proto file is
Run this command (lets pretend the name of my .proto file is “afunprotofile”) “protoc –matlab_out=./ -I./ afunprotofile.proto”
The easiest way is to use Java
The FarSounder code was nice, but it is quite old and unmaintained. The easiest way to produce Matlab compatible code is to just use the Java version of Protobuf. This solution should work on any platform that supports Matlab and Java.
The Steps
Create a .proto file
Process the file with the protoc compiler and output Java source
Using IntelliJ or other tool produce a JAR file that includes the dependencies
Add the JAR file to the Matlab classpath. edit('classpath.txt')
Restart Matlab
The protobuf runtime dependencies
I include these in a single JAR file output of the Protobuf and the two runtime libraries.
protobuf-java-3.3.0.jar
protobuf-java-util-3.3.0.jar
A sample
I wrote a simple Java wrapper class to hide the MyProtobuf.Builder return type from Matlab that I added to the JAR file
public class MyProtobufWrapperWrapper {
public static MyProtobuf.Builder newBuilder()
{
return MyProtobuf.newBuilder();
}
}
In Matlab
p = com.cameronpalmer.MyProtobufWrapper.newBuilder();
p.setIdentifier(java.util.UUID.randomUUID().toString());
p.setTimestampMilliseconds(timestamp);
p.setAngleRadians(0);
p.addAllChannelSamples(channel_vector);
planeWaveBuilt = p.build();
byteArray = planeWaveBuilt.toByteArray();
As Cameron Lowell Palmer's answer suggests, the way to go is via Java.
Is I lost a couple of hours today on this problem, I would like to elaborate some more. I started with Cameron's answer but I had to do a couple of more steps. Essentially, I had to do all of the following:
Compile proto message for java, e.g. protoc --java_out=./ your_file.proto
Remember to install protobuf java runtime, e.g. in ubuntu: sudo apt install libprotobuf-java
Locate the protobuf java runtime on your system, e.g.: /usr/share/java/protobuf-3.6.1.jar; its path will be used later on. The name should always follow the pattern protobuf-version.jar or protobuf-java-version.jar, therefore locate protobuf- | grep jar$ should reduce the search space for you.
Add a short java file to the same directory, where your protobuf java files went (./x/y/z/MyProto.java). Use your package path instead of x/y/z. If you did not declare java package explicitly in the proto file, then protoc just used your filename as package name. Either way, you can probably check where the protoc generated files went by yourself. Contents of MyProto.java are listed below. Just replace YourProtoFileName and YourMessageName with your stuff. Note that this step is not optional, as this will not generate a simple helper class. For the life of me, Matlab would not let me use inner classes directly (in java, YourMessageName is the inner class of YourProtoFileName). But with the above helper, it was quite happy to generate them for me. Note that if you have more than one message defined in your proto file, you might need to expose more than one builder in this way. And if you only need to read protobuffers, then you might need to export just YourMessageName and not Builder.
package x.y.z;
import x.y.z.YourProtoFileName; // if you do not know it, do `ls x.y.z/*.java`
public class MyProto {
public static YourProtoFileName.YourMessageName.Builder newBuilder() {
return YourProtoFileName.YourMessageName.newBuilder();
}
}
Check Matlab's version of java; in Matlab write version -java. In my case it was 1.8, while the default java installed on my system (java -version) is 11. I had to manually select java 1.8 for the next step, otherwise the whole thing did not work. Even worse, Matlab only produced a very nondescript error "No class x.y.z.YourProtoFileName." Thanks Matlab! You might need to install proper version first (sudo apt install openjdk-8-jdk) and then use update-java-alternatives or just locate javac for the appropriate java version on your system.
Compile both your java file and the one generated by protoc. Remember to point classpath at the jar file or protobuffer runtime that you found above. And remember to use your javac path. In a single command: /usr/lib/jvm/java-8-openjdk-amd64/bin/javac x.y.z/*.java -cp /usr/share/java/protobuf-3.6.1.jar. This will generate class files in ./x/y/z/.
Optional: pack the class files in a jar for easier distribution: jar cvf ./YourProtoFilename.jar x/y/z/*.class. Note that this command line works for me, since I've put all classes, including MyProto, in the same package. You might need to adapt it to your needs.
Start Matlab.
% make Matlab aware of your new classes
javaaddpath('./')
% tell Matlab where protobuf dependancy lives (use the path from step 3)
javaaddpath('/usr/share/java/protobuf-3.6.1.jar')
% test if the classes were found
methods('x.y.z.YourProtoFilename.YourMessageName')
% if methods are listed then you are good to go
% use the helper form step 4
b = x.y.z.MyProto.newBuilder();
% now you have a builder you can use to build your protobuf message
See Google's protobuf java primer to go on from here, as using java in Matlab is fairly straight forward: just write java statements. As long as they are simple statements :)
The same procedure works on octave too. With a bit different syntax for java inside octave. And octave was less picky about the java version in my case. YMMV
#WPFUser,
We followed below steps to build protoc for matlab.
1) git clone https://github.com/protocolbuffers/protobuf.git to protobuf-main folder
2) git submodule update --init --recursive
3) git clone https://github.com/farsounder/protobuf-matlab.git - protobuf_matlab folder
4) Copied src folder from protobuf_matlab repo to protobuf-main/src
5) Updated cmake/libprotoc.cmake to include matlab_generator.cc and matlab_generator.h files
6) Updated cmake/extract_includes.bat.in to include matlab_generator.h file
7) \src\google\protobuf\compiler\main.cc to include matlab_generator

Netbeans, phpdocumentor, and custom phpdoc.dist.xml by project

I am using Netbeans 8.0.2 and phpdocumentor 2.8.2 on a windows 7 platform.
I would like to use custom phpdoc.dist.xml config files by project so I can specify framework directories and etc. to exclude from the generated doc. I also want to keep my Netbeans PHPDOC plugin config as generic as possible, without specific output directories, ignore options, config path parameters, etc., so on, so that that the config will apply to all my projects.
The phpdoc.dist.xml file works great. The doc generated is exactly what I want.
The problem or feature, and it seems to be a phpdocumentor one as it also applies from plain command line, is that the phpdoc.bat command (without a specific config parm) has to be run from the same root directory as the phpdoc.dist.xml file, or it ignores it. No problem if I'm using command line as I can change into that directory first, but I would like to use Netbeans. I have searched on this extensively and cannot find an answer.
I considered whether to modify the phpdocumentor files to insert cd /D path/to/myproject/dir to change the directory using some Netbeans variable to represent myproject/dir, but I could not find the right place in the code or the variable to use. Plus, then I'm supporting a custom mod to phpdocumentor.
I did find these directions for a PHPStorm setup, where the author specified a PHPStorm variable for the --config command line option to point to his custom phpdoc.dist.xml.
--config="$ProjectFileDir$/phpdoc.dist.xml"
If I could do the same in Netbeans like maybe "${BASE_DIR}/phpdoc.dist.xml" it would be great, but so far I haven't hit on anything Netbeans will recognize/pay attention to in the PhpDoc script: box.
I have also tried writing a wrapper .bat file to capture my own command line variable %1 and do the directory change to that before calling phpdoc.bat, but Netbeans throws and error and says that's not a valid .bat file. I cannot find any phpdocumentor parameter to configure by specific Netbeans project but the output directory. And I would prefer not to be defining a bunch of projects on subdirectories in Netbeans, just to address phpdocumentor.
Now I am out of ideas. Can anyone point me to a solution?

Can't generate documentation with phpdocumentor 2 with Netbeans

Using Netbeans "Generate PHPDoc", I'm able to generate the structure.xml for my project, but I'm at a lost as to how to get from that XML file to the fully generated phpdoc.
I was finally able to generate my HTML files. I simply needed to activate the XSL extension manually by editing php.ini in WAMP.
I must admit that due to my lack of skills with the command line, it was somehow difficult to follow instructions that are given out on the web.