Visual C++ :: CString Class In Non-MFC Static Library

Sep 13, 2013

I have a non-MFC static library which I share between a number of different projects, some non-MFC and some MFC. Currently the static library uses a typedef of std::wstring and std::string for UNICODE and non-UNICODE builds.

After discovering it's possible to use CString in non-MFC applications, by including atlstr.h header, I decided I'd rather that than using stl strings and having to keep converting between the different types. However, I seem to be struggling with linker errors when linking the library with a MFC application.

Can I create a non-MFC static library using CString from atlstr.h and link it with a MFC application?

View 11 Replies


ADVERTISEMENT

C++ :: Shared Library Vs Static Library?

Jan 17, 2014

I've been reading about libraries; How to make them, how to use them, the different types of libraries, etc..

When using a shared library, does the program require that library to be installed on the computer after the program has been compiled into an .exe?

Ie.. if somebody downloaded a "Helloworld.exe" that I had compiled on my computer using a shared library (that wasn't part of a standard operating system), would they also need that shared library on their computer for the program to run without errors?

and for Static Libraries, when I compile a program using a static library, does it include in the final binary only the functions of the library that are actually used, or does the compiler add in the entire library?

View 8 Replies View Related

Visual C++ :: Static Class Member In Multithreaded Environment

Nov 21, 2014

I have a class having static member.I have get and set methods which will Get and Set Values to this variable. In a multithreaded application does it have any thread safety issues.

Class a {
static int b;
void Set (int c);
int Get();
};

View 10 Replies View Related

C++ :: Do Static Functions Have Access To Non Static Data Members Of A Class

Apr 17, 2013

From my book:

"A static function might have this prototype:

static void Afunction(int n);

A static function can be called in relation to a particular object by a statement such as the following:

aBox.Afunction(10);

The function has no access to the non-static members of aBox. The same function could also be called without reference to an object. In this case, the statement would be:

CBox::Afunction(10);

where CBox is the class name. Using the class name and the scope resolution operator tells the compiler to which class Afunction() belongs."

Why exactly cant Afunction access non-static members?

View 7 Replies View Related

C :: Static Library Linking

Oct 7, 2014

I am trying to refresh my memory here as I did some studies many years ago but the results elude me.Also todays c/c++ compilers may have better optimizations.Say I have a static library that includes three obj modules.Each of these object modules has a number of functions. These functions do not reference any other functions within the obj module.My main app links this library but only references one function from each of the object modules.

Question: Are the complete contents of each module linked into my main app or are todays linkers smart enough to just link the functions used?

View 4 Replies View Related

C++ :: Build Own Library (static)

Sep 11, 2014

How to build the static library on my own using visual C++ 2008.

I used the following code to create the header file and cpp of the library.but I am unable to compile due to the following error.

// MathFuncsLib.h
namespace MathFuncs {
class MyMathFuncs {
public:
// Returns a + b
static double Add(double a, double b);

[Code] .....

Error I get while it is compiled :
Error3error C2653: 'MyMathFuncs' : is not a class or namespace name

View 4 Replies View Related

C++ :: How To Link Static Library

Mar 31, 2013

How to create standalone program. For now I have simple program connecting to MySql Database and when i run it, shows me error, libmysql.dll is missing... When i put libmysql.dll in same folder works. Now my question is, how in code blocks can i compile so i won't require libmysql.dll anymore and be able to use it on any machine.

View 1 Replies View Related

C++ :: Linking Static Library To CPP File

Jun 20, 2013

I have a libcx3d.a which contains my VrmlParser class and other classes which are used by VrmlParser. I have a main.cpp which does this :

VrmlParser vp = new VrmlParser();
double **VOB = vp.getVOB();

When I compile using g++ main.cpp -o main -L. -lcx3d, I get the following errors :

'VrmlParser' was not declared in this scope.
expected ';' before vp.
'vp' was not declared in this scope.

There is a header file called "VrmlParser.h" in the static library. Should I include this header file in main.cpp ? If so, will include "VrmlParser.h" work ? I have the .a and .cpp in the same directory. I can't find the header file for the static library.

View 9 Replies View Related

C++ :: Linking To Static Library That Contains A Macro

Jul 16, 2014

I have built a static library that contains a macro. From a separate exe, I am calling this macro, but it doesn't work.

The compilation of the static library and that of the exe went okay.

Static lib contains just the macro definition.

Exe contains call to this macro.

Is there anything else that I need to do for this to work?

View 4 Replies View Related

C++ :: Static Linking Boost Library

Dec 17, 2014

I have written a program that uses boost in visual studio 2012. The only boost library I used is filesystem by doing.

1)Properties->Linker->General and adding the path or the .lib to the additional dependencies. The libraries, link at compile time.However when i move the exe to a different computer, it doesn't work. Therefore the libraries were dynamically not statically linked. So my question is how do I statically link the filesystem library, so that i can include boost/filesystem.hpp in visual studio 2012?

View 1 Replies View Related

C++ :: Using Global Variables In Static Library

Jul 22, 2014

Is it possible to use & change global variables in a Static Library? For example:

I declare a
bool test = true;
globally.

Then later in an exported function If the user wants, he can set that test to false. So the program later when checks test if it's true, will notice that it's not true, since one of my function changed it.

Is it right?

View 3 Replies View Related

C++ :: Making Static Library With MinGW

Jul 5, 2012

There is a file compressor called FreeArc (that has GPL code) and a sub project called Unarc (meant for file extraction only) that is free for any use.

Their source codes can be downloaded from here: [URL] ....

Unarc has a makefile for making a dll. I am trying to make it static instead (.a file), using MinGW, but am failing.

If I use the .o files compiled by the makefile to make one .a file, the decompression methods don't seem to be recognized as they should, so I can't extract anything. These decompression methods are added through static functions called withing the .cpp files of each method, so I guess their code is not being executed.

View 14 Replies View Related

C# :: Static Method Inside Non-static Class

Aug 22, 2014

Have following code:

class Program
{
static void Main(string[] args)
{

[Code]....

My question according to what i just wrote:

1. Is that mean that Do() is only available for use by Dog itself because Dog is 'oryginal' Dog, and if i create new dogs - instances of oryginal Dog (dog1, dog2 ...) they cant access because Do is only available fo 'oryginal' one? Is that correct thinking?

2. If i would want to have something common (e.g value) for all dogs is that good way to create static field/method for Dog instead of non-static once then all instances of Dog would access Dog static member to get/change it? Just stupid example: static method GetAmountOfLegs() which return 4 Then all instances can take/call that value from Dog. Is that correct thinking?

View 2 Replies View Related

C++ :: Application That Has One Static Library Dependency - Linking Error

Feb 16, 2012

I am trying to build an application that has one static library dependency, however I am getting this error when linking:

1>ClCompile:
1> All outputs are up-to-date.
1>LINK : fatal error LNK1104: cannot open file 'TestWrapperLib.obj'

Why I might be getting that? I have the .lib in the depends line, and the directory where it is at in the include line.

View 1 Replies View Related

Visual C++ :: Can't Initialize Struct With CString

Apr 7, 2013

I'm trying to compile the following and it doesn't work? How can I get the CString to initialize.

Code:

struct print {
int x; //row
int y; //col
int fid;
CString *data;
char *format;

[Code] .....

the char *format is not a problem, but compiler doesn't like CString *data;

tried CSting data and that also doesn't work, typecasting didn't work either?

View 14 Replies View Related

Visual C++ :: First Chance Exception CString

Jul 9, 2014

Why would the following line of code cause an exception and how can I fix it? This is with Visual Studio 2013 and it is set to use "Multibyte Character Set". This is a very old program that I was updating.

Code: thepath = dadir + "*.csv";

Both dadir and thepath are type CString.

Prior to this line dadir looks fine when I look at it in the debugger but when I reach this line of code I get

First-chance exception at 0x0FA08EE1 (mfc120d.dll) in GAQUtilities2014.exe: 0xC0000005: Access violation reading location 0xFEFEFFC6.

View 5 Replies View Related

Visual C++ :: Array Of CString Size Checking

Apr 4, 2014

Code:
//Class header
CString m_cstrArry[5];

Code:
//Class source
void Ctry4Dlg::OnInitDialog() {
m_cstrArry[0] = _T("TEXT 0 |");
m_cstrArry[1] = _T("TEXT 1 |");
m_cstrArry[2] = _T("TEXT 2 |");

[Code] .....

View 8 Replies View Related

Visual C++ :: Detecting Garbage Chars In CString

Feb 1, 2013

How do I detect garbage chars in a CString. Actually I'm reading some data from COM port. In some certain condition it will give some garbage as a version no. Now I need to show _T("N/A") in case of there is any garbage.

My solution is to check for a Valid char or integer. If found its correct else Garbage.

View 11 Replies View Related

Visual C++ :: Converting ASCII To CString Not Working In 6.0?

Sep 22, 2012

The below code is working fine in VS2008 and not working in VC6.0 (taking garbage values) this code is for converting hex values to string.

sending Input string is : 727332333263 required output: rs232c

DWORD AsciiToString(LPCTSTR f_chInputChar, LPTSTR f_chOutputChar) {
long ch;
int i,j;
TCHAR tmp[2];
int len = _tcslen(f_chInputChar);

[Code] ....

View 5 Replies View Related

Visual C++ :: CString - Display Some Data In Text Format On A Dialog

Aug 7, 2014

I am trying to display some data in text format on a dialog and I am using a CString to do it. Below is how I coded it.

Code:
CString outputStr;
CString auxStr;
// Add header
outputStr.Format("");
auxStr.Format("%-7s%-20s%-7s%-20s%s

[Code] .....

But the output rows are not aligned as shown in the attached picture. There a two problems.

1. Data rows don't align with the header row.
2. When the first element of a row changes to two digits, the other elements are shifted.

According to MSDN [URL] ...., CString::Format() works the same way as printf(). I wrote a small program using printf() to do the same thing, and the output in the console are perfectly aligned.

What have I missed when doing the display in GUI?

View 14 Replies View Related

C++ :: How To Initialize Static Member Of Class With Template And Type Of Nested Class

Oct 7, 2014

How to initialize a static member of a class with template, which type is related to a nested class?

This code works (without nested class):

#include<iostream>
using namespace std;
struct B{
B(){cout<<"here"<<endl;}
};
template<typename Z>

[Code] ,....

View 1 Replies View Related

C++ :: Make Class Created Static Inside Another Class?

Dec 17, 2013

it seems everytime i use statics in a class i come across with a porblem.

this time i wanted to make a class i created static inside another class.

MainVariables.h file
static fge::window mWinMain;

if someone ever wants to reach it
MainVariables.cpp file

fge::window MainVariables::mWinMain;
...
...
fge::window MainVariables::GetWinMain()
{
return mWinMain;
}

but when i created some other MainVariables classes at other places instead of them reaching to the same window two window is being created.

yes i know maybe there are better methods but currently i m working on polymorphism and i need some static members.

View 2 Replies View Related

C++ :: Undefined Reference To (method Name) When Accessing Method In Static Library

Jan 17, 2013

I've been trying for more than one month to access a method found in a library called libcocosnas_static.a. I'm using Cocos2d-X version 2.0.4. The library has been used many times by my company to make games using cocos2d-1.0.1-x-0.12.0 without any problem.

This is what I've done:
1- I added the include paths of the library to both eclipse and Android.mk
2- Included the .h file using #include "NASPlatformUtil.h"
3- Added the libcocosnas_static.a file to the proj.androidobjlocalarmeabi folder
4- Added "LOCAL_WHOLE_STATIC_LIBRARIES += cocosnas_static" to the Android.mk file
5- Called the function using: NASPlatformUtil:: openUrl("http://xxx.xxx.com/");

I can right click on the function, click Open Declaration and get it without any problem, but the compiler keeps on giving me that dreaded error...

View 3 Replies View Related

C++ :: CPLEX Library - Using A Class In Other Class

Jan 27, 2012

I want to use CPLEX library in c++. The variables of this library can not be defined as poitners (because it does not work so). Therefore, I had to define them statically as follows:

IloEnv env_;
IloModel model_(env_);
...

As class IloModel has not defult constructor, the env_ variable should be passed in the definition.

Now, I want to define class Solver which uses cplex. How can I define env_ and model_ as the members of Solver? If I define them statically as follows:

Class Solver {
IloEnv env_;
IloModel model_(env_);
}

There will be a compile error with defining model_. On the other hand, it is not possible to define Solver as follows and "new" it in the constructor:

Class Solver {
IloEnv env_;
IloModel* model_;
}

View 3 Replies View Related

C++ :: In Class Static Map Initialization

Nov 17, 2014

I have a class containing a map member that I want to initialize at declaration time. I know I can do it in the cpp file but I'm having a problem with the order of initialization (static initialization order fiasco).

My questions are:

Is it possible that the scenario in which, the Test's constructor's implementation and the map initialization instruction are in the same cpp file and constructor is called when the map is not initialized yet, could happen?

Is it possible to initialize the map in class like I did? I get these errors:

in-class initialization of static data member 'std::map<std::basic_string<char>, Test*> Test::a' of incomplete type
temporary of non-literal type 'std::map<std::basic_string<char>, Test*>' in a constant expression

If yes, does this initialization resolve the static initialization order fiasco?

class Test {
public:
static std::map<std::string, Test*> a = {};//this is an error
Test(std::string ID) {

[Code] ....

View 4 Replies View Related

C++ :: Static Object Of Same Class

Jul 27, 2013

What is the purpose of having static object of the same class.

E.g.

class someObj{
public:
static someObj obj;
};

how the compiler treats this object

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved