C/C++ :: Run A Public Domain Code In Molecular Dynamics?
Jul 27, 2014
I need to run a public domain code in Molecular Dynamics. I have a Knoppix 7.2 system with Geany and gcc 4.7.2-5 and g++ 4:4.7.2-1 .
I need to compile this code and create a binary but can't.
The output:
gcc -o md md.c
/tmp/ccODg4eA.o: In function `compute':
md.c:(.text+0x718): undefined reference to `sin'
md.c:(.text+0x72a): undefined reference to `pow'
md.c:(.text+0x794): undefined reference to `sin'
/tmp/ccODg4eA.o: In function `dist':
md.c:(.text+0x8f9): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
note that since this is a Public Domain code, I have not altered it. The main code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <string.h>
int main ( int argc, char *argv[] );
void compute ( int np, int nd, double pos[], double vel[],
double mass, double f[], double *pot, double *kin );
I'm trying to analyze Population Dynamics. I found some articles and read them but what kind of model i need to use. I tried Forest Fire model but i failed in modificating.
I have some requirement regarding implementing a C program .exe to implement on Domain computers as a Startup/Logon script. I created a C program which is meant to be run on domain PCs when they start/Login. This .exe program runs some DOS commands using system function, then writing output to few files. I then pick up required information from files & prints it on to a console screen. While creating this program using C compiler, it gathers all the info & prints to screen properly. It uses following commands in program:
Code:
reg export "...." "c:windowswebwallpaper eg_xport.txt" Here "..." means some registry path e.g. HKLM... etc.
Code:
systeminfo > "c:windowswebwallpapersys_info.txt" wmic qfe get installedon > " c:windowswebwallpaperpatches_date.txt"
Two issues over here are that 'reg export' to a file and 'wmic' require admin privileges on domain PC & thus the program should carry admin rights while executing. I got this solved by putting this program to run as startup script. The program runs, creates files and removes them also(as a part of program), but shows no output on screen (from screen I mean console screen). I then created a plain "Hello" program and implemented it on few domain PCs, I guess script got executed but nothing came up on the screen.
I am not sure what is happening at backend. Whether the program is able to execute only DOS commands & skip all other IF/ELSE/WHILE conditional loops. Or these are executing but PRINTF is not able to launch a console screen. Printing output to screen is must in order to pass message to users using PCs.
I have added sql browser & sql server in fire wall, and also enabled tcp port 1433 and udp port 1434. the above connection string works perfect when i run it in the server machine, but whenIi try to run it on other machines I am getting an error that server is not available or cannot find the specified server.. I desperately need to access my database through an url. ie., through internet..
This is a winsock program designed to prompt the user to enter a domain name. The program is then supposed to return to the user a resolved ip address of that domain name. The user should also be able to enter an IP address and receive back a domain name.
While the program prompts the user to enter the domain name, all that is ever returned is error#:0
HTML Code: // Declare and initialize variables #include <winsock2.h> #include <ws2tcpip.h> #include <stdio.h> #include <windows.h> #pragma comment(lib, "ws2_32.lib") #include <iostream> int main(int argc, char **argv) { hostent* remoteHost;
I've been writing my own implementation of quicksort in a .h file. I've gotten to the point where I think I'm done with the algorithm, so now I'm trying to make it so that if someone includes "quicksort.h", they will only have access to certain functions in the file. Kind of like public and private functions in a class, but without the "class" part of it. How do you do that?
I have read the book over and over and I thought I understand "CLASS". But when I applied it and write the code the compiler tells me that there is a compiling error.
1. I have this method addProduct(Product* pProduct) in a Class called ProductRack, the code is in ProductRack.cpp file. The declaration of the Class methods and private variables are in ProductRack.h header file.
2. But when I call a method in the DeliveryCHute Class from the ProductRack Class I get a compiler errors which are these:
A.IntelliSense: a nonstatic member reference must be relative to a specific object B.error C2352: 'Project1::DeliveryChute::insertProduct' : illegal call of non-static member function
And this is causing the error:
if (Project1::DeliveryChute::insertProduct(pProduct) == false)
//THIS IS JUST ONE METHOD INSIDE ProductRack.cpp bool Project1::ProductRack::addProduct(Product* pProduct) { // Todo : Implementing if (Project1::DeliveryChute::insertProduct(pProduct) == false) return true;
error C2995: 'foo<l+r> operator *(const foo<s> &,const foo<r> &)' : function template has already been defined see declaration of 'operator *' see reference to class template instantiation 'foo<s>' being compiled with [ s=4 ]
If I change the operator to return a foo<s> it does compile (but that's not the behaviour I need).
if I move the operator to outside the class (removing the 'friend') it does compile and behaves how I need, but I can't access non-public members so I can't write the implementation correctly.
I've finally managed to do something with the combo box but knock down one wall it's like there's another one five inches behind it. What I mean is I've figured out how to add items to the combo box and have them show images in my picture box. Only problem is when I went to debug my combo box kept looping it's options over and over and over.
Private Sub xpmaleskincolorselect.Items.Add("Tone1"); malesprite.Image = My.Resources.Resources.XP_Female_clear; xpmaleskincolorselect.Items.Add("Tone2"); malesprite.Image = My.Resources.Resources.XP_Male_tan; xpmaleskincolorselect.Items.Add("Tone3"); malesprite.Image = My.Resources.Resources.XP_Male_dark; End Sub
The subs, I know they aren't right but its just to show I know where they go. Anyway using Private Sub and End sub doesn't seem to work. I'll type them in then at the error box at the bottom it'll say that it doesn't exist in the namespace. Same thing happened when I tried to add public class beforehand to see if that would work same thing about the name space.
I'm trying to create a public and static field in a class called ResourceManager. But when trying to access the field even from inside the class it wont work. I'm getting this error message:
Error 1 error LNK2001: unresolved external symbol "public: static int ResourceManager::num" (?num@ResourceManager@@2HA)
Here's my code: ResourceManager.h
Code:
class ResourceManager { public: static int num; static void loadContent();
class DataBase { // Change the connection path here to your own version of the database public SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;AttachDbFilename=|DataDirectory|UberDatabase.mdf;Integrated Security=True;"); public DataBase() { } }
And in the same namespace as this class I have a form that calls it like so:
DataBase dBase = new DataBase(); SqlCommand trythis = new SqlCommand("Register", dBase.con);
However, I'm getting the field initializer error on dBase.con. I'm not sure why, but when I call the database from another file (program.cs) it works fine this way.
I have a class 'A' which is almost perfect for my needs. Class 'B' uses class 'A' I've now designed Class 'C' and Class 'D' and noticed that there is a good chunk of code in class 'B', 'C' and 'D' for using Class 'A' is duplicated. I've separated out this code in specific, standalone functions in each of the classes. Now I'm wondering where this code should go. At the moment, the functions are duplicated in the three calling classes (B, C and D). Placing the functions into class 'A' would break the single responsibility principle. Inheritance to add functionality would likely break both SRP and LSP. The one that seems that it may work is composition.
However, Is designing a complete class just for a few functions over kill?
Would it be valid for classes 'B', 'C' and 'D' to access both the new class 'E' (which would depend on A) and the old class 'A' (which would have to be the same instance as the instance in the new class 'E'), or should the new class 'E' provide sufficient functionality so that Classes B, C and D don't need to access Class A directly? It would seem that its then an incomplete interface of the original object with additional functionality (ie, incompatible) Or should I do it a completely different way?
I am making a game and want to make an updater that grabs the source code from a page on the web. Can this use things that are available to all platforms? It could just be something that grabs the text from the page and executing it (maybe using something like Python's exec() command ?) BTW I'm using mac
this is my code i want to put the part where i have it do multiplication and addition into functions. and then call them so that it can run the addition and multiplication. Heres my code
# include <iostream> using namespace std; int main(){
I'm pretty new to C++ and I'm on Binary Trees in "Jumping into C++"! I've just created a DLL project on Code::Blocks, and I cannot get it to build and run: "You must select a host application to "run" a library..." is the message that I'm getting when I run the main code file. It's had no changes to it (except for a few extra, unnecessary line feeds), and it's the file which Code::Blocks generates on a DLL project.
whats wrong with this code, I'm trying to parse a .js file and replace all the ";" with "; " i.e add a new line after each ";". So I load the file into a char[] buffer then assign a string to this contents of this buffer. Then loop char by char through using an iterator and check for a ";", if found use replace. So int i gets to about 85898 then crashes with unknown error, 'i' should reach about 175653. It does work up till it crashes. And, is this not a simpler way to load a file into a buffer, there is in C.
I have a function that needs to return a "uint8_t" value. However before doing the processing I need to perform a test on the argument to check if it's between expected boundaries. Although this function works it gives (a logical) warning that not always a value is returned although expected. What is the normal way for functions like these where I normally should return e.g. -1 in case the test doesn't succeed and otherwise the uint8_t (t) value?
Code: uint8_t myFunc(int a) { if (a >= 0 && a <= 100) { // Perform actions uint8_t = ... return t; } }